Search

Monday, February 3, 2014
0 comments

Array Function in PHP Programming

2:26 AMMonday, February 3, 2014
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’);
8/*

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

$arary=array(1,2,3,4);
$s=sizeof($arrray);
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);
array_reverse($array);
after execute this code the array will be
$array=array (4,3,2,1);
Protected by Copyscape Online Copyright Protection Software

0 comments :

Post a Comment

 
Toggle Footer
Top