Hello, I am having one array and its having 3 values. I want to insert the value at second position of array and re-arranging the rest of the elements accordingly. How can I do this in easiest way in PHP? Please help me. Thanks in advance...
there must be better option that escape me at the moment but this will work
foreach($your_array as $k=>$v){ if($k == 1){ //2nd array value $new_array[]='NEW VALUE'; $new_array[]= $v; }else{ $new_array[]= $v; } }
array_splice($your_array, 1, 0, 'new value');
Doh!
thanks a lot... this is exactly what i need!! 🙂 thanks once again!!!