A ctype_space() function in PHP is used to check whether each and every character of a string is whitespace character or not. It returns True if the all characters are white space, else returns False.
- text :- It is a mandatory parameter which specifies the string.
Returns TRUE if every character in text contains white space, return false otherwise. the blank character this also includes tab, carriage, vertical tab, line feed, and form feed characters.
Input : Output : Yes Explanation: is create white space Input : abc Output : No Explanation: characters "abc" are not white space
Below programs illustrate the ctype_space() function.
Program 1: taking a single string
Program: 2 Taking an array of string and checking for whitespace using ctype_space() function
No No Yes
Takes an example ctype_space() function how to work string in both single quotes ‘ ‘ and double quotes ” ” symbol.
No Yes No Yes
This article is attributed to GeeksforGeeks.org