Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Voting

: three plus five?
(Example: nine)

The Note You're Voting On

phpnet at holodyn dot com
11 years ago
Since 5.4 STRICT standards dictate that you cannot wrap array_keys in a function like array_shift that attempts to reference the array.

Invalid:
echo array_shift( array_keys( array('a' => 'apple') ) );

Valid:
$keys = array_keys( array('a' => 'apple') );
echo array_shift( $keys );

But Wait! Since PHP (currently) allows you to break a reference by wrapping a variable in parentheses, you can currently use:

echo array_shift( ( array_keys( array('a' => 'apple') ) ) );

However I would expect in time the PHP team will modify the rules of parentheses.

<< Back to user notes page

To Top