<?php
$array = array (
0 =>
array (
'id' => 1,
'user_id' => 15,
'booked' => '2020-08-01',
'sendin' => '2020-08-03',
'pickup' => '2020-08-08',
'duration' => 5
),
1 =>
array (
'id' => 2,
'user_id' => 15,
'booked' => '2020-08-01',
'sendin' => '2020-08-03',
'pickup' => '2020-08-08',
'duration' => 5
)
);
$user_id = 15;
$ids = array_map(function ($a) { return $a['id']; },
array_filter($array,
function ($a) use ($user_id) {
return $a['user_id'] == $user_id;
})
);
print_r($ids);
$ids = array_map(function ($k) use ($array) { return $array[$k]['id']; },
array_keys(array_column($array, 'user_id'), $user_id)
);
print_r($ids);
preferences:
23.84 ms | 408 KiB | 5 Q