In this tutorial learn how to search index of the value in an array, Search for the index of a value in an array.
TUTORIAL
OUTPUT DEMO:
function search($array, $value)
{
return array_search($value, $array, true);
}
TUTORIAL
<?php $array = Array ( 'id' => 2, 'user' => 4, ); /** * Search for the index of a value in an array. * * @param array $array * @param string $value * * @return mixed */ function search($array, $value) { return array_search($value, $array, true); } echo search($array,2);
OUTPUT DEMO:
id
No comments:
Post a Comment