PHP array_slice() null length results in empty array -


i have array want use array_slice remove first element of array. here's command:

$myarray = array_slice($myarray, 1); 

now, array_slice has 4th argument, when set true, preserves array keys instead of resetting them. need option set true.

the 3rd argument specify length of resulting array. supposed leave argument out if want array sliced end of array instead of specifying length.

so tried this:

$myarray = array_slice($myarray, 1, null, true); 

and results in empty array. doing wrong? there way "leave out" length argument without setting null? because setting null seems empty array completely.

also, workaround this:

$myarray = array_slice($myarray, 1, count($myarray)-1, true); 

but doesn't seem should have that...

update

this appears bug php 5.1.6

i tested code:

$myarray = array( 'test1' => 'test1', 'test2' => 'test2', 'test3' => 'test3', 'test4' => 'test4', );  var_dump(array_slice($myarray, 1, null, true)); 

and works fine me showing test2, test3, , test4.

this run on 5.2.13. try upgrading php (i know should dev box).


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -