On Sun, 2004-05-09 at 21:13, PHPDiscuss - PHP Newsgroups and mailing
lists wrote:
> I'm using list like
> list($a,$b,$c,$d) = $MyArray
> MyArray holds more than three items, 0-4 more,
> my problem is that $d only gets one and I lose the others if more tha one
> extra. I know I can just add more $e,f,g,h,i but how do I get the extras
> into an array?

Try using array_shift[1] for the first few items instead of list:
$a = array_shift($MyArray);
$b = array_shift($MyArray);
$c = array_shift($MyArray);

$MyArray will have the leftovers, you can just assign it if you need a
copy:
$d = $MyArray;

If you only want $d to be an array when there is more than one entry
left do this instead:
if (count($MyArray) == 1) {
 $d = array_shift($MyArray);
} else {
 $d = $MyArray;
}

[1] http://www.php.net/array_shift

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to