casit
asked on
php checking chars help
Does anyone have a function to check for spaces and to make sure length is not over 20 chars?
ASKER
@gawai Not what I was lookin for. I was looking for something that checked a string to see if it had spaces OR if it was over 20 characters.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks
<?php
function wordcount($str) {
return count(explode(" ",$str));
}
// Example Usage:
$test = "This String has five words.";
echo "There are " . wordcount($test) . " in the sentence";
?>