Loop through an associative array


SUBMITTED BY: henry1874w

DATE: June 17, 2017, 1:09 p.m.

FORMAT: Text only

SIZE: 225 Bytes

HITS: 227

  1. <!DOCTYPE html>
  2. <html>
  3. <body>
  4. <?php
  5. $age = array("Peter"=>"35", "Ben"=>"37", "Joe"=>"43");
  6. foreach($age as $x => $x_value) {
  7. echo "Key=" . $x . ", Value=" . $x_value;
  8. echo "<br>";
  9. }
  10. ?>
  11. </body>
  12. </html>

comments powered by Disqus