Simple Array Example Learn PHP Programming Creating Arrays Learn Tutorial

RegisterLogin
Simple Array Example Learn PHP Programming Creating Arrays Learn Tutorial
Post Description: Simple Array Example Learn PHP Programming Creating Arrays Learn Tutorial
Tags: Simple, Array, Example, Learn, PHP, Programming, Creating, Arrays, Learn, Tutorial
This Post Was Posted On Feb 29, 2008 By unix #1227
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
Administrator
#1667 1
take a look at this tutorial. it helped me alot

how-to-index-arrays-and-show-all-the-elements-and-values-of-array

Feb 24, 2008 Reply Report abuse
©2011 Webune Forums - Wed Dec 21, 2011 5:27 am
Powered by: Webune Forums V3