arrays - PHP Insert at particular index -
i want move element of array present @ 1st index 5th index in array. how can that?
if mean "move", can this
$from = 1; $to = 5; $el = $array[$from]; unset($array[$from]); $array = array_merge ( array_slice($array,0,$to), array($el), array_slice($array,$to));
cant test it, idea is: take , remove element @ $from
original array, split rest @ $to
, merge together. maybe index in array_slice()
not match exactly;)
Comments
Post a Comment