($data, 'baz'));
print_r(array_key_by($data, Array('baz', 'bar')));
print_r(array_key_by($data, Array('baz', 'bar', 'foo')));
?>
In reply to Drewseph using foo($a = 'set'); where $a is a reference formal parameter.
$a = 'set' is an expression. Expressions cannot be passed by reference, don't you just hate that, I do. If you turn on error reporting for E_NOTICE, you will be told about it.
Resolution: $a = 'set'; foo($a); this does what you want.
If you set a variable before passing it to a function that takes a variable as a reference, it is much harder (if not impossible) to edit the variable within the function.
Example:
<?php
function foo(&$bar) {
$bar = "hellon";
}
foo($unset);
echo($unset);
foo($set = "setn");
echo($set);
?>
Output:
hello
set
It baffles me, but there you have it.
The order in which you reference your variables matters.
<?php
$a1 = "One";
$a2 = "Two";
$b1 = "Three";
$b2 = "Four";
$b1 =& $a1;
$a2 =& $b2;
echo $a1; echo $b1; echo $a2;
8/11 首页 上一页 6 7 8 9 10 11 下一页 尾页 |