Advertisement
Gepoko

Minabo PHP

Apr 3rd, 2014
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.30 KB | None | 0 0
  1. <?php
  2. $miarray = array(
  3.     128 => 1,  
  4.     64  => 0,  
  5.     32  => 1,    
  6.     16  => 0,    
  7.     8   => 1,    
  8.     4   => 1,    
  9.     2   => 1,    
  10.     1   => 0,   );
  11.  
  12. $suma=0;
  13. foreach ($miarray as $indice => $clave)
  14. {    if($clave==1){        
  15.     $suma += $indice;
  16.     }
  17. }
  18. echo $suma;
  19. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement