<?php
...
$words = preg_split('/[[:space:]]+/',$mynewstring);
foreach ($words as $word) {
$freq[$word]++;
}
ksort($freq);
print_r ($freq);
?>
Sort does not work seamlessly. I have my key and
sort($freq);
print_r ($freq);
looks like:
Array
(
...
[1000] => 172
[1001] => 176
[1002] => 179
[1003] => 441
)
This is what I want:
Array
(
...
[and] => 172
[of] => 176
[to] => 179
[the] => 441
)
http://php.net/manual/en/array.sorting.php is pretty clear. But my
problem is that sort ($freq) destroyed my key.