How to check if a string consists of all whitespace characters in PHP

1 Answer

0 votes
$s = " \n\r\t";
if (ctype_space($s))
    echo "yes<br />";
else
    echo "no<br />";

$s = "\nabc";
if (ctype_space($s))
    echo "yes<br />";
else
    echo "no<br />";

 
/*
run:
  
yes
no
  
*/

 



answered Dec 7, 2016 by avibootz
...