Advertisement
Guest User

Array multidimensional

a guest
Aug 6th, 2018
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.41 KB | None | 0 0
  1. <?php
  2.  
  3. $cores = array (
  4.     'vermelhas' => array ('maçã','morango','cereja','acerola'),
  5.     'verdes' => array ('banana','melão'),
  6.     'amarelas' => array ('abacate','kiwi','pera')
  7. );
  8.  
  9. ?>
  10.  
  11. <?php foreach( $cores as $cor => $frutas ): ?>
  12.     <p>
  13.         <p><?php echo $cor; ?></p>
  14.         <ul>
  15.             <?php foreach( $frutas as $fruta ): ?>
  16.                 <li><?php echo $fruta; ?></li>
  17.             <?php endforeach ?>
  18.         </ul>
  19.     </p>
  20. <?php endforeach ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement