Adsense 728 * 15


Custom Search

Associative Array in php

Associative Array

In associative array we use index name instead of number.

For example-

Suppose we want to categorize the the total number of books available in different categories. so using name of different categories is better than using index number. 


$books = array ( "novels" => "150.00", "inspirational" => "146.00", "sports" => "200.00");  

foreach($books as $key => $value)
  echo $key."  ".$value." <br />";  //print the array elements


It can also be declared as

$books['novels'] = "150";
$books['inspirational'] = "146";
$books['sports'] = "200";

No comments:

Post a Comment