Advertisement
linuxyamigos

Untitled

Mar 29th, 2020
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.29 KB | None | 0 0
  1.  
  2.  
  3. $municipios = [];
  4. foreach ($consulta as $persona){
  5.     if (!in_array($persona.municipio, $municipios)){
  6.         $municipios[$persona->municipio] = 0;
  7.     } else {
  8.         $municipios[$persona->municipio]++;
  9.     }
  10. }
  11.  
  12. echo "Las personas pertencen a ".count($municipios)." distintos";
  13.  
  14. var_dump($municipios);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement