Appending an Array to another
=============================
Use Built-in array_merge function.
<?php
$ar1=array("Green","Red","White");
$ar2=array("Red","Blue","Violet");
$add=array_merge($ar1,$ar2);
foreach ($add as $element){print $element;
print "<br>";}
?>
You can also + sign to merge the files.$add=$ar1+$ar2;If you dont want to lose
elements that are same in both arrays, you can use the array_merge_recursive()
function.
Reversing an array
==================
use built-in array_reverse function.
<?php
$ar=array("Green","Red","White");
$ar=array_reverse($ar);
foreach ($ar as $element){
print $element;
print "<br>";
}
?>
ASSICIATIVE ARRAY
=================
Associative array has "String Index Association". Associative array represent
relationship.For example "Sachin is Cricket Star", you can represent it as
<?
$star['Cricket']="Sachin";
?>
Constructing associative array is similar to Normal array but you have to
specify both the value and the key.
<?
$star=array("Cricket"=>"Sachin");
?>
Adding new elements in an associative array
===========================================
<?php
//to add a star
$stars=array("Kapil"=>"Cricket, "Anna"=>"Tenis", "Maradona"=>"Football");
$stars["MJ"]="BasketBall";
?>
Deleting elements in an associative array
=========================================
Use unset buit-in function for deleting n element , you can pass a single element or
a whole array into it.
Moving through an Associative Array
===================================
use foreach loop
<?php
foreach ($ar as $key=>$value){
//operations
}
?>
*To merge two arrays you can use array_merge() function or simple use +sign
$ar1+$ar2