FatCow Plan for $3.67/mo. only HostPapa 100% Green Energy Web Hosting
Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to use associative array in php?
04-29-2012, 11:57 AM (This post was last modified: 04-29-2012 05:24 PM by bex_spin0.)
Post: #2
RE: How to use associative array in php?
(04-25-2012 03:15 AM)phpdeveloperindia Wrote:  How to use associative array in php?

An associative array also stores data in the same way but gives you more flexibility by letting you assign any name you want to your keys instead of using keys 0, 1, 2, 3, 4, and so on. This is helpful when you want to assign a certain value to your key.

For example, you want an array which display the height of school children in cm, your associative array function will look like this:

<?php
$height=array('Billy'=>90, 'Sam'=>95, 'Susie'=>92, Tamara=>89);
?>

To retrieve the value for each key you just have to type in:
echo $height ('Billy'); or
echo $height ('Sam'); and so on.

Hope this helps.

I will code for food.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: How to use associative array in php? - bex_spin0 - 04-29-2012 11:57 AM

Forum Jump:


User(s) browsing this thread: 1 Guest(s)