Advertisement
touhid_xml

Loop associative array through for loop

Dec 13th, 2014
487
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. $city = [ "Dhaka" , "Dinajpur" , "Rangpur"];
  4.  
  5. for($i=0; $i<count($city); $i++){  // count($city) will count the elements under the city array condition look like (0<3)
  6.    echo "{$city[$i]}<br />\n"; //when $i == 0 it will be act like $city[0], when $i == 1 it will be act like $city[1]
  7. }
  8.  
  9.  ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement