// Array representing a possible record set returned from a database
$records = array(
array(
'id' => 2135,
'first_name' => 'John',
'last_name' => 'Doe',
),
array(
'id' => 3245,
'first_name' => 'Sally',
'last_name' => 'Smith',
),
array(
'id' => 5342,
'first_name' => 'Jane',
'last_name' => 'Jones',
),
array(
'id' => 5623,
'first_name' => 'Peter',
'last_name' => 'Doe',
)
);
$id = array_search(5623, array_column($records, 'id'));
print_r($records[$id]);
Reference :
1) https://stackoverflow.com/questions/6661530/php-multidimensional-array-search-by-value
2) https://vijayasankarn.wordpress.com/2017/02/20/array_unique-for-multidimensional-array/
Reference :
1) https://stackoverflow.com/questions/6661530/php-multidimensional-array-search-by-value
2) https://vijayasankarn.wordpress.com/2017/02/20/array_unique-for-multidimensional-array/
No comments:
Post a Comment