Link to home
Start Free TrialLog in
Avatar of casit
casitFlag for United States of America

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?
Avatar of Emad Gawai
Emad Gawai
Flag of United Arab Emirates image


<?php
function wordcount($str) {  
  return count(explode(" ",$str));
}  

// Example Usage:
$test = "This String has five words.";
echo "There are " . wordcount($test) . " in the sentence";
?>
Avatar of casit

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
Avatar of tkalchev
tkalchev
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of casit

ASKER

Thanks