Array Function in PHP Programming

February 03, 2014 0 Comments

Array functions: - PHP provide various functions to perform different operations on array like searching, sorting, merging, splitting etc.  Here we have some important php functions which used to perform major operations on PHP array.

sort():- This function is used to sort the array according to its value. For example

$names=array (‘a’,’c’’b’);
Sort ($names);
After execute this funcitn the array will be
$names=array (‘a’,’b’’c’);

sizeof():- This function is used to determine size of array. This function return number of elements available in that array. For example

Here in $s we have 4. This is size of this array.

array_merge():- This function is used to merge two array. For example

$first = array ('hello', 'world');    
$second = array ('exit', ‘here’);    
$merged = array_merge ($first, $second);
After execute this code the $merged array will be
// $merged = array ('hello', 'world', 'exit', 'here')

•     array_reverse() :- This function is used to reverse the array elements. For example

$array=array (1,2,3,4);
after execute this code the array will be
$array=array (4,3,2,1);

Weilems Jon

Some say he’s half man half fish, others say he’s more of a seventy/thirty split. Either way he’s a fishy bastard. Google