ctype_space to check all whitespace character(s)

bool ctype_space ( string $input_string )
$input_string : String to be checked.

ctype_space() is a PHP filter function checks the presence of whitespace character(s) in the $input_string . Any thing other than this if present then it return FALSE.

$str = array('string1' => "\n\t\r", 'string2' => "Hello World", 'string3' => "asd\n\r\t",'string4' => 45);
foreach ($str as $val => $string) {
if (ctype_space($string)) {
 echo "<p class='text-success'>The string <b>$val</b> consists of all  whitespace character(s)</p>";
}else {
 echo "<p class='text-danger'>The string <b>$val</b>  consist of non-whitespace character(s)</p>";
 }
}
Output is here

The string string1 consists of all whitespace character(s)

The string string2 consist of non-whitespace character(s)

The string string3 consist of non-whitespace character(s)

The string string4 consist of non-whitespace character(s)



Subscribe to our YouTube Channel here


Subscribe

* indicates required
Subscribe to plus2net

    plus2net.com




    Post your comments , suggestion , error , requirements etc here .




    We use cookies to improve your browsing experience. . Learn more
    HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
    ©2000-2023 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer