PHP Count Words in a string

Count Words in a string

<?
$string = "Random text"; 
$count = count(explode(" ",$string)); 
echo "$count words";
?>