how to get index of repeated data from a multi dimension array using array_search() or array_column() method
function Search($value, $array)
{
return(array_search($value, $array,false));
}
$array = array(45, 5, 1, 22, 22, 10, 10);
$value = "10";
$index1= Search($value, $array);
echo $index1;
this displays index of first '10' from array. How do I get index of 2nd 10 from the array in $index2 varaible. Please help this will help me a lot.
It is described in array_search
manual:
function Search($value, $array)
{
return array_keys($array, $value, false);
}
$array = array(45, 5, 1, 22, 22, 10, 10);
$value = "10";
$indexes = Search($value, $array);
print_r($indexes);
You can see full documentation of array_keys
here