PDA

Click to See Complete Forum and Search --> : Array find value


slice
Mar 26th, 2006, 01:42 PM
Is it possible to find index of array where values is "any value" ?

Suppose there is array from index 0 to 99 and have same values stored 0 to 99.

And we want to find the index of array where value is "35".

I need some fast solution otherwise it can done thru for loop. :rolleyes:

da_silvy
Mar 27th, 2006, 02:18 AM
<?php
$array = array(0 => 'blue', 1 => 'red', 2 => 'green', 3 => 'red');

$key = array_search('green', $array); // $key = 2;
$key = array_search('red', $array); // $key = 1;
?>