PHP Ctype_space () Function

PHP

Syntax:
ctype_space (string text)
Parameter used :
  • text: -is a required parameter that specifies a string.
Returned value:
Returns TRUE if each character in the text contains a space, otherwise returns false. this empty character also includes tab, carriage, vertical tab, line feed, and line feed.Examples :
Input: Output: Yes Explanation: is create white space Input: abc Output: No Explanation: characters "abc" are not white space
The programs below illustrate the ctype_space() function. 
Program 1:taking one line
// PHP program to check the given string
// space character or not $string = " / n / t / r " ; if (ctype_space ( $string )) echo " Yes " ; else echo " No " ; ?>
Exit:
No
Program: 2Taking an array of strings and checking for spaces using the ctype_space() function
// PHP program for checking the given string
// space character or not $strings = array ( 'y xuo' , "gfg" , "" );  
// Checking the above lines
// using the ctype_space() function. foreach ( $strings as $testcase ) { if (ctype_space ( $testcase )) { echo "Yes" ; } else { echo "No" ; } }
?>
Exit:
No No Yes
Program: 3
Consideran example function ctype_space(),how to handle a string in both single and and in double quotes. " < tbody>
// PHP program for checking the given string
// space character or not  $strings = array ( '' , "" , '' , "" );  
// Checking the above lines
// using the ctype_space() function. foreach ( $strings as $testcase ) {   if (ctype_space ( $testcase )) { echo " Yes " ; } else { echo "No" ; } }
?>
Exit:
No Yes No Yes
Links: http://php.net/manual /en/function.ctype-space.php



Get Solution for free from DataCamp guru