Voting

: nine minus nine?
(Example: nine)

The Note You're Voting On

kermes [at] thesevens [dot] net
16 years ago
A variation of previous searches that returns an array of keys that match the given value:

<?php
function array_ksearch($array, $str)
{
$result = array();
for(
$i = 0; $i < count($array); next($array), $i++)
if(
strtolower(current($array)) == strtolower($str))
array_push($result, key($array);

return
$result;
}
?>

Usage would be as follows:
<?php
$testArray
= array('one' => 'test1', 'two' => 'test2', 'three' => 'test1', 'four' => 'test2', 'five' => 'test1');
print_r(array_ksearch($testArray, 'test1'));
?>

<< Back to user notes page

To Top