note 45273 added to function.list
| From: | webmasteratmy-x-periencedotde at osu1 dot php dot net | Date: | Tue, 31 Aug 2004 22:04:53 +0000 |
| Subject: | note 45273 added to function.list | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-75769@lists.php.net to get a copy of this message | ||
As pgl at instinct dot org said it will not work when you use something like this
<?php
$a = "a:b";
list($a['x'],$a['y']) = explode(":",$a);
?>
so I tried using a temporary variable to store the data
<?php
$a = "a:b";
$temp = explode(":",$a);
list($a['x'],$a['y']) = $temp;
print_r($a);
// will output a:b
?>
it seems that list() does not overwrite existing variables if they are not the type array
you don't get the expected result unless you unset the original variable
<?php
$a = "a:b";
$temp = explode(":",$a);
unset($a);
list($a['x'],$a['y']) = $temp;
print_r($a);
// will output Array( [y] => b [x] => a)
?>
----
Manual Page -- http://www.php.net/manual/en/function.list.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+45273
Delete -- http://master.php.net/manage/user-notes.php?action=delete+45273&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+45273&report=yes
Search -- http://master.php.net/manage/user-notes.php