English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The ctype_space() function checks if the characters in the provided string contain whitespace.
ctype_space( $text );
Check if the characters inside the provided string text contain whitespace.
Serial Number | Parameters and Description |
---|---|
1 | text (required) The string being tested. |
If each character in text is ultimately output in some form of whitespace, return TRUE; otherwise, return FALSE. This includes whitespace characters, indentation, vertical tab, newline, carriage return, and formfeed characters.
Check if the characters inside the string elements of the array contain whitespace
<?php $strings = array('string1=> "\n\r\t", 'string2=> "\narf"12", 'string3=> '\n\r\t'); foreach ($strings as $test) { if (ctype_space($test)) { echo "$test is composed of whitespace characters.\n"; }else { echo "$test contains non-whitespace characters\n"; } } ?>Test to see‹/›
Output result:
Composed of whitespace characters. arf12 Non-whitespace characters contained Non-whitespace characters contained