Skip to content

Instantly share code, notes, and snippets.

@jeremy5189
Created June 18, 2013 13:09
Show Gist options
  • Save jeremy5189/5805205 to your computer and use it in GitHub Desktop.
Save jeremy5189/5805205 to your computer and use it in GitHub Desktop.
PHP Array Group By
<?php
$str = array("a","a","a","b","b","c","d","d","d");
foreach( array_count_values($str) as $item => $count ) {
for( $i = 0; $i < $count; $i++ ) {
echo $item."<br/>";
}
echo "<hr/>";
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment