PHP array tutorial


Home - Tutorials - Basics

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.

Step 1 - Introduction to arrays


PHP array tutorial


Arrays are special data types. Despite of other normal variables an array can store more than one value. Let's suppose you want to store basic colors in your PHP script. You can construct a small list from them like this:

Color list:

It is quite hard, boring, and bad idea to store each color in a separate variable. It would be very nice to have the above representation almost as it is in PHP. And here comes array into play.

The array type exists exactly for such purposes. So let's see how to create an array to store our color list.




Next 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

Partners
AJAX F1
CSS F1
Database F1
Forex F1
Flash F1
HTML F1
JavaScript F1
PhotoShop F1
PHP F1
MaxTutorial
Monthly mortgage payment calculator
WebFormGenerator

Forex mini accounts

Total time: 0.0086