PHP Array tutorial - Array functions
In this tutorial I will show you how to work with arrays in PHP. You will learn how to create, sort or print an array. Besides this we will touch on multidimensional arrays as well.
|Name:||PHP Array tutorial|
Bookmark PHP Array tutorial
Step 6 - Array functions
PHP Array tutorial
During programming it can be neccessary to manipulate arrays. Do do this PHP has some usefull built in functions.
Get the length of the array, or with other words how many elements are in the array. To get this information you can use the sizeof function. It tells you how big is the actual data. You can use it like this:
Sometimes you want to remove an element from the array. In this case you can use the unset function like this:
isset function as follows:
sort and asort. The difference between them is that sort renumbers the keys so you will lost the key values. So if you need the key names (associative arrays) use the asort function.
You can use them as follows:
rsort and arsort functions.
On the last page you will find a complete example code which demonstrates array handling.
Previous Step of PHP Array tutorialNext Step of PHP Array tutorial
Tags: array, php array, sort array, create array, print array, array length
|PHP Array tutorial - Table of contents|
|Step 1 - Introduction to arrays|
|Step 2 - Creating an array|
|Step 3 - Display the array content|
|Step 4 - Associative arrays|
|Step 5 - Multidimensional arrays|
|Step 6 - Array functions|
|Step 7 - Complete example code|