Monday, 2 September 2013

How to remove the first element of array without changing its key value?

How to remove the first element of array without changing its key value?

I have an array in php
<?php
$array=array("a"=>"123","b"=>"234","c"=>"345");
array_shift($array);
//array("0"=>"234","1"=>"345");
?>
If I use this function, then key value gets changed. I want my key value
to remain the same. How can I remove first element without affecting array
key values. My answer should be like
array("b"=>"234","c"=>"345");
Note:Please do not use foreach(); I want to do this by existing array
functions in php

No comments:

Post a Comment