Write a PHP script to select first 6 words from the following string

Write a PHP script that inserts a new item in an array in any position

Introduction

PHP is a server scripting language, and It is a powerful tool for making interactive and dynamic Web-pages. I have used WampServer 2.2 for following excercise..

<?php
$original = array( '10','20','30','40','50','60' );
echo 'Original array : '."<br>";
foreach ($original as $x) 
{echo "$x ";}
$inserted = '#';
array_splice( $original, 4, 0, $inserted ); 
echo " <br> After inserting '#' the array is : "."<br>";
foreach ($original as $x) 
{echo "$x ";}
echo "<br>"
?>

Result

Write a PHP script that inserts a new item in an array in any position
Write a PHP script that inserts a new item in an array in any position

Add a Comment

Your email address will not be published. Required fields are marked *