PHP - Function ctype_space()


Advertisements


Syntax

ctype_space ( $text );

Definition and Usage

This function checks if all of the characters in the provided string, text, creates whitespace.

Parameters

Parameter Description
text Required. The tested string.

Return Value

Returns TRUE if every character in text creates some sort of white space, FALSE otherwise. Besides the blank character this also includes tab, vertical tab, line feed, carriage return and form feed characters.

Example

Try out following example −

<?php
   $strings = array('\n\r\t', '\narf12' );
   
   foreach ($strings as $testcase) {
      if (ctype_space($testcase)) {
         echo "$testcase consists of all whitespace characters. \n";
      }
      else 
      {
         echo "$testcase does not have all whitespace characters. \n";
      }
   }
?> 

This will produce the following result −

\n\r\t does not have all whitespace characters.
\narf12 does not have all whitespace characters.

php_function_reference.htm

Advertisements