Write a PHP script that inserts a new item in an array in any position
<?php $original = array( '1','2','3','4','5' ); echo 'Original array : '."\n"; foreach ($original as $x) {echo "$x ";} $inserted = '$'; array_splice( $original, 3, 0, $inserted ); echo " \n After inserting '$' the array is : "."\n"; foreach ($original as $x) {echo "$x ";} echo "\n" ?>
Sample Output:
Original array : 1 2 3 4 5 After inserting '$' the array is : 1 2 3 $ 4 5
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Sample Output:
need an explanation for this answer? contact us directly to get an explanation for this answer