Advertisement
nenhumdeucerto

Desafio 001

Apr 13th, 2018
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.83 KB | None | 0 0
  1. <?php
  2.  
  3. function mostrar($p){
  4.     $tot = count($p);
  5.     for ($i=0; $i<$tot; $i++){
  6.         $tot1 = count($p[$i]);
  7.         echo "<div style='display:flex;'>";
  8.         for($y=0; $y<$tot1;$y++){
  9.             if ($p[$i][$y]==0){
  10.                 echo "<div style='width:10px;height:10px;background:#000;'>  </div>" ;
  11.             } elseif ($p[$i][$y]==1){
  12.                 echo "<div style='width:10px;height:10px;background:#FFF;'>  </div>" ;
  13.             } else {
  14.                 echo "<div style='width:10px;height:10px;background:#000;border-radius:50%'>  </div>" ;
  15.             }
  16.         }
  17.         echo "</div>";
  18.     }
  19. }
  20.  
  21. $array = array(
  22.     array(0, 0, 0, 0, 0, 0),
  23.     array(0, 1, 1, 1, 1, 0),
  24.     array(0, 1, 2, 1, 1, 0),
  25.     array(0, 1, 1, 2, 1, 0),
  26.     array(0, 1, 1, 1, 1, 0),
  27.     array(0, 0, 0, 0, 0, 0)
  28. );
  29.  
  30. mostrar($array);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement