Remove elements from an array and replace it with new elements with the length parameter set to 0 in PHP

Description

The following code shows how to remove elements from an array and replace it with new elements with the length parameter set to 0.

Example


/*from  w  w w.j av a  2 s . c o  m*/
<?php
    $a1=array("0"=>"red","1"=>"green");
    $a2=array("0"=>"purple","1"=>"orange");
    array_splice($a1,1,0,$a2);
    print_r($a1);
?>

The code above generates the following result.





















Home »
  PHP Tutorial »
    Data Types »




Array
Array Associative
Array Util
ArrayObject
Data Types
Date
Date Format
DateTime
Number
String
String Escape
String Filter
String HTML
String Type
Timezone