Re: array_shift not working?

From: Date: Sat, 01 Oct 2005 20:59:13 +0000
Subject: Re: array_shift not working?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-223497@lists.php.net to get a copy of this message
Frank Keessen schrieb: > Can you please help me with the following > This is in the array($info[0]["bdnadvocaat"]) > Array ( [count] => 2 [0] => 210 [1] => 149 ) > This is the code: > $testje=array($info[0]["bdnadvocaat"]); > $test=array_shift($testje); > print_r($test); > This is the output > Array ( [count] => 2 [0] => 210 [1] => 149 ) > How can i remove the 'count' from the array? array_shift works "in situ", it operates on the array insted of returning a new one. Also you are using array(), whichs builds an array of its argument(s). Suppose you have Array ( [count] => 2 [0] => 210 [1] => 149 ) in $info[0]["bdnadvocaat"]. Then $testje=array($info[0]["bdnadvocaat"]); will result in having Array ( [0] => Array( [count] => 2 [0] => 210 [1] => 149 )) in $testje. An array with just one value! Afterwards doing $test=array_shift($testje); will remove the first element from $test and give it as result. Afterwards you have $test == Array ( [count] => 2 [0] => 210 [1] => 149 ) $testje == Array ( ) If you simply want to remove the first element from $info[0]["bdnadvocaat"], you can simply array_shift($info[0]["bdnadvocaat"]) which removes count. AllOLLi ____________ "That fact was conveniently omitted." [Enterprise 409]

« previous php.general (#223497) next »