How do you define an array?

Indexed Arrays

Two ways to create indexed arrays

1) Index can be assigned automatically

$cars = array("Volvo", "BMW", "Toyota");

2) Index can be assigned manually:

$cars[0] = "Volvo";
$cars[1] = "BMW";
$cars[2] = "Toyota";

Associative Arrays

$age = array("Peter"=>"35", "Ben"=>"37", "Joe"=>"43");
or 
$age['Peter'] = "35";
$age['Ben'] = "37";
$age['Joe'] = "43";

Multidimensional Arrays

$cars = array (
  array("Volvo",22,18),
  array("BMW",15,13),
  array("Saab",5,2),
  array("Land Rover",17,15)
);

Pay Nowfdggf !

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments