Re: array_shift not working?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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]

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux