Search This Blog

Thursday, March 21, 2013

How to Print the Key and Value of PHP Array?

$data = array(
    "1"   => "One",   
    "A" => "Apple",
    "B"    => "Ball",
    "C"  => "Cat"
);

foreach ($data as $key => $value)
{
  echo $key."=".$value;
  echo "<br/>";
}

Output:


1=One
A=Apple
B=Ball
c=Cat

No comments:

Post a Comment