Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //Associative arrays in PHP
- // and the foreach method
- $arr = array('Rob', 'Bob', 'Robert', 'Bobby', 'Mr. Paulson');
- $assoc = array('Brad'=>'Tyler Durden', 'Ed'=>'The narrator', 88 => 'Five', 'Helena'=>'Marla Singer');
- $assoc[] = 'Robert Paulson';
- //foreach($arr as $k => $name){
- foreach($arr as $nm){
- //echo $k . ' - ' . $name . '<br/>';
- echo $nm . '<br/>';
- }
- foreach($assoc as $key => $name){
- echo $key . ' - ' . $name . '<br/>';
- }
- ?>
Add Comment
Please, Sign In to add comment