Learning arrays was one of the harding part for me to learn when programming in php or any other similar languages like C++. Today i will show you how you can create a simple array and display the array with a for loop so it will display the numbers 0 through 5 on the screen. So this is how i will show you:
1. you will need to have a website with PHP. If you don't have PHP on your website, you can visit our friends at Webune.com They have very good service PHP Hosting.
2. a text editor - If you have windows, you can use notepad.
now copy and paste the following code into your text editor and save it as loop.php
Code:<?php
# Create by Wallpaperama.com
#
$numbers = array(0,1,2,3,4,5);
for($counter =0; $counter <= 5; $counter++)
{
echo 'Array'.$counter.' = '.$numbers[$counter].'<BR>';
}
?>
Now open it with your browser and this is what it will show:
Code:Array0 = 0
Array1 = 1
Array2 = 2
Array3 = 3
Array4 = 4
Array5 = 5