Example:
list($fruit1, $fruit2) = array('apples', 'oranges');
code above of course works ok, but code below:
list($fruit1, $fruit2) = array('fruit1' => 'apples', 'fruit2' => 'oranges');
gives: Notice: Undefined offset: 1 in....
Is there any way to refer to named keys somehow with list like list('fruit1' : $fruit1), have you seen anything like this planned for future release?
EDIT: This approach was useful back in the day (it was asked & answered nine years ago), but see Kerem’s answer below for a better approach with newer PHP 7+ syntax.
Try the
extract()function. It will create variables of all your keys, assigned to their associated values: