You are here: Re: array_shift not working? « PHP « IT news, forums, messages
Re: array_shift not working?

Posted by Oliver Grδtz on 10/01/05 23:59

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]

 

Navigation:

[Reply to this message]


УдалСнная Ρ€Π°Π±ΠΎΡ‚Π° для программистов  •  Как Π·Π°Ρ€Π°Π±ΠΎΡ‚Π°Ρ‚ΡŒ Π½Π° Google AdSense  •  England, UK  •  ΡΡ‚Π°Ρ‚ΡŒΠΈ Π½Π° английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Π‘Π°ΠΉΡ‚ ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ Π² Π‘Ρ‚ΡƒΠ΄ΠΈΠΈ Π’Π°Π»Π΅Π½Ρ‚ΠΈΠ½Π° ΠŸΠ΅Ρ‚Ρ€ΡƒΡ‡Π΅ΠΊΠ°
ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ΠΈΠ΅ ΠΈ ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠ° Π²Π΅Π±-сайтов, Ρ€Π°Π·Ρ€Π°Π±ΠΎΡ‚ΠΊΠ° ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠ½ΠΎΠ³ΠΎ обСспСчСния, поисковая оптимизация