I have a foreach wich return data like below:
foreach($array_users as $key => $item) {
$dwn_users = array();
$dwn_users = "USER_ID ". $item['user_id'] . " USER_ROOMS " . base64_decode($item['user_rooms']);
}
print_r($dwn_users);
USER_ID 2 USER_ROOMS a:8:{i:0;s:2:"49";i:1;s:2:"60";i:2;s:2:"69";i:3;s:2:"65";i:4;s:2:"66";i:5;s:2:"59";i:6;s:2:"71";i:7;s:2:"57";}
USER_ID 3 USER_ROOMS a:1:{i:0;s:2:"49";}
USER_ID 4 USER_ROOMS a:4:{i:0;s:2:"49";i:1;s:2:"60";i:2;s:2:"65";i:3;s:2:"58";}
I'm like to create new array with list of USER_ID with access to certain room example: $room = '60';
How to search IN $dwn_users for room 60 and create new array of user ID? In this case an array with USER_ID 2 and USER_ID 4
Although that I don't think that your foreach
loop will produce the output you have mentioned because you are re-define the array for each row,
for your question, this will generate an array with the user id as the key and the user rooms as value:
$dwn_users = array();
foreach($array_users as $key => $item) {
$userid = $item['user_id'];
$dwn_users[$userid] = base64_decode($item['user_rooms']);
}