Advertisement
linuxyamigos

Untitled

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