Skip to content

Instantly share code, notes, and snippets.

@MihailoJoksimovic
Created August 27, 2013 08:14
Show Gist options
  • Save MihailoJoksimovic/6350954 to your computer and use it in GitHub Desktop.
Save MihailoJoksimovic/6350954 to your computer and use it in GitHub Desktop.
<?php
$word = "Stefane ides u kurac stefane pusis kurac samo kurac da da da!";
$split = explode(" ", strtolower($word));
$map = array();
foreach ($split as $v) {
if (isset($map[$v])) {
$map[$v]++;
} else {
$map[$v] = 1;
}
}
asort($map);
print_r($map);
dig@dev:tmp$ php test.php
Array
(
[pusis] => 1
[samo] => 1
[da!] => 1
[u] => 1
[ides] => 1
[da] => 2
[stefane] => 2
[kurac] => 3
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment