$ids = array_column($users, 'id');
<?php
$search_array = array('first' => 1, 'second' => 4);
if (array_key_exists('first', $search_array)) {
echo "The 'first' element is in the array";
}
?>
$array = array(0 => 'blue', 1 => 'red', 2 => 'green', 3 => 'red');
$key = array_search('green', $array); // $key = 2;
$key = array_search('red', $array); // $key = 1;
foreach($yourArray as $key => $value) {
echo '<a href="' . $value . '">' . $key . '</a>';
}
// OR
//Use functions
key($array); //Returns current key
reset($array); //Moves array pointer to first record
current($array); //Returns current value
next($array); //Moves array pointer to next record and returns its value
prev($array); //Moves array pointer to previous record and returns its value
end($array); //Moves array pointer to last record and returns its value
$people = array(
2 => array(
'name' => 'John',
'fav_color' => 'green'
),
5=> array(
'name' => 'Samuel',
'fav_color' => 'blue'
));
$found_key = array_search('blue', array_column($people, 'fav_color'));