add element in a particular position in an array

add element in a particular position in an array

<?php
$input = array("red", "green", "blue", "yellow");
$input1 = array_slice($input,2);
$input2 = array_splice($input,2);
array_push($input1, "apple", "raspberry");
$input3=array_merge($input1,$input2);
//print_r($input3);

$input = array("red", "green", "blue", "yellow");
array_splice($input, 2, 0, "purple");
print_r($input);
?>

Usage

add element in a particular position in an array


Comments

markpaul7931
Posted on 22.07.2019 08:01

This is the best article and Thanks for sharing this important information wit us. outsource seo india work well in the form of digital marketing.

Add your comment