Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created July 9, 2021 01:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/79f2f9a815dfffb1e02e080c3af0ae4e to your computer and use it in GitHub Desktop.
Save parzibyte/79f2f9a815dfffb1e02e080c3af0ae4e to your computer and use it in GitHub Desktop.
<?php
// https://parzibyte.me/blog
$diccionario = [
1 => 0,
2 => 0,
3 => 0,
4 => 0,
5 => 0,
];
$miArray = [1, 2, 1, 3, 3, 1, 2, 1, 5, 1];
foreach ($miArray as $numero) {
$diccionario[$numero]++;
}
foreach ($diccionario as $clave => $conteo) {
echo "$clave: ";
for ($x = 0; $x < $conteo; $x++) {
echo "*";
}
echo "\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment