That's strange, try this:
<?php
$text = 'apple banana cheese dog elephant fish';
$anagrams = explode (' ' , $text);
shuffle($anagrams);
foreach ($anagrams as $anagram)
{
echo $anagram . "<br />\n";
}
?>
If you happen to get the words in the original order, refresh the page (a few times if necessary, but that is unlikely to be needed). If you are using a version of PHP before 4.2, then also use [man]srand/man or [man]mt_srand/man, or simply upgrade.