Ajax Tutorials, PHP Tutorials, Javascript Tutorials, Visual Basic.Net Training, XHTML tutorials, php script library, PHP Codes, Programming tutorials, web development tutorials
Web Development Tutorials, Programming Tutorials, PHP Script Index
Home | Forums | Downloads | Books | Submit Content | Links

Programming Articles

  PHP articles
  MySql articles
  Visual Basic.Net articles
  Java articles
  ASP articles
  ASP.Net articles
  Visual Basic articles
  CSS articles

Programming Tutorials

  PHP tutorials
  MySql tutorials
  Visual Basic.Net tutorials
  Java tutorials
  ASP tutorials
  ASP.Net tutorials
  Visual Basic tutorials
  HTML tutorials
  CSS tutorials

Programming Source Codes

  PHP scripts
  Visual Basic.Net scripts
  JavaScript scripts
  ASP scripts
  ASP.Net scripts
  Visual Basic scripts

Our Partners

  Free Resources
  Publisherbank
  Free Link Directory
  PHP Magazine
  Webmaster Passion
  Search Engine Bank
  Free Directory Site
  Free PHP Scripts
  Links Shopping Mart
  Variety Bazar
  Urdu Office Tutorials
  Evernew Scripts
  Evernew Scripts
  Evernew Directory
  Our Achievements
  Web templates
  Buy and Sell Templates
  Text Link Traders
  Directory Metro
  Gifts Choice
  Valentines Ecards
  Template Directory

Arrays in PHP

Date:2006-03-19

An Array is a list variable that can store and index multiple values. An array is useful when the data you want to store has something in common or is logically grouped into a set

you can create an array using array() function, this function have one or more arguments, Let's define an array called $animals and assign four strings to it:

$users = array ("cat", "dog", "fish", "rabbit" );


echo $array[0]; //returns "cat"
echo $array[1]; //returns "dog"
echo $array[2]; //returns "fish"
echo $array[3]; //returns "rabbit"


Now each item of the array is accessed using the variable name, followed directly by square brackets containing the number of the item to be accessed. The number listing of the array starts at zero, so the first item is 0, second is 1, third is 2, etc.

Array looping
If you want to store multiple values in array, it will takes you quite some time to type in one by one. Instead of typing it, you can use 'foreach' statement to loop all the value within an array.
<?php
$animals= array("dog", "cat", "goat");
foreach($animals as $key => $value) {
echo $key . " " . $value . "<br>";
}
?>
And the result will be
0 dog
1 cat
2 goat



Desclaimer | Privacy Policy | Submit Content | Links | Link to Us | Sitemap |Contact Us
Copyright Programming Tutorials, Web Development Tutorials, Source codes © All Rights are Reserved.
Powered By Evernew Solutions

Wills - Renegade motorhomes - New York Hotels - Debt Help