www.pickatutorial.com Computer Tutorials
Top Tutorials: C/C++ | C#.NET | PHP MySQL | Java | Java Script | jQuery | HTML | xHTML | HTML5 | VB Script| CSS
Lessons PHP Array Functions Bookmark and Share
Lesson 1
Lesson 2
Lesson 3
Lesson 4
Lesson 5
Lesson 6
Lesson 7
Lesson 8
Lesson 9
Lesson 10
Lesson 11
Lesson 12
Lesson 13
Lesson 14
Lesson 15
Lesson 16
Lesson 17
Lesson 18
Lesson 19
Lesson 20
Lesson 21
Lesson 22
Lesson 23
Lesson 24
Lesson 25
Lesson 26
Lesson 27
Lesson 28
Lesson 29
Lesson 30
Lesson 31
Lesson 32
Lesson 33
Lesson 34
Lesson 35
Lesson 36
Lesson 37
Lesson 38
Lesson 39
Lesson 40
Lesson 41
Lesson 42
Lesson 43
Lesson 44
Built-In Functions
The following functions are part of the numerous functions that make up the PHP language. This is a very small list of what the PHP offers. These are among the most useful of PHP functions that a PHP developer needs to use regularly. If you are interested and want more please visit the PHP manual at http://www.php.net/manual.

PHP Array Functions
Various PHP functions are available for use with arrays. The most useful of them are discussed here.

PHP array() function
The array() function allows us to manually assign values to an array. Here is how this works:

$array_name = array("value1", "value2", "value3", ...);

PHP array_push() function
The array_push() function allows us to add one or more elements to the end of an existing array. Let's see how this works:

array_push($array_name, "element 1", "element 2", "element 3", ...);

PHP array_pop() function
The array_pop() function allows us to take (pop) off the last element of an existing array. It return the last element of the array and removes the same from the array. Let's see how this works:

array_pop($array_name);

PHP array_merge() function
The array_merge() function allows us to combine two or more existing arrays. Here is how this works:

array_merge($array1, $array2, ...);

PHP array_keys() function The array_keys() function returns an array of all the key names in an existing array. Its syntax follows:

array_keys($array_name);

PHP array_values() function
The PHP array_values() function returns an array of all the values in an existing array. The syntax follows:

array_values($array_name);

PHP count() function
The PHP count() function returns the number of elements in a variable. We usually use this function to get the number of elements of an array, as a variable that is not an array has only one element. Let's see how this works:

$numberOfColors = count($colors);

PHP reset() function
The PHP reset() function resets the pointer to the beginning of the array. Here is how it works:

reset($array_name);

PHP shuffle() function
The PHP shuffle() function randomizes the elements of a given array. Its syntax follows:

shuffle($array_name);

PHP sizeof() function
The PHP sizeof() function returns the number (count) of elements in an array. It works similar to the PHP count() function. Let's see it syntax:

$numberOfColors = count($colors);


Home - Advertise - Contact - Disclaimer - About Us
© Since 2006 pickatutorial.com -- All Rights Reserved.