Example #1
0
<?php

function &array_find_value($needle, &$stack)
{
    foreach ($stack as $key => $value) {
        if ($needle == $value) {
            return $stack[$key];
        }
    }
}
$arr = ['a', 'b', 'the door'];
$band =& array_find_value('the door', $arr);
$band = 'ddd';
var_export($arr);
<?php

function array_find_value($needle, &$haystack)
{
    foreach ($haystack as $key => $value) {
        if ($needle == $value) {
            return $key;
        }
    }
}
$minnesota = array('Bob Dylan', 'F. Scott Fitzgerald', 'Prince', 'Charles Schultz');
$prince = array_find_value('Prince', $minnesota);
// The ASCII version of Prince's unpronounceable symbol
$minnesota[$prince] = 'O(+>';
<?php

$band =& array_find_value('The Doors', $artists);