Php701 Essay

1664 WordsAug 10, 20147 Pages
Choose any five string functions from the list of string functions done in class (chapter 3) and explain it with examples. You do not have to write a program for it and just need to give examples. strlen — gets string length Description int strlen ( string $string ) Returns - the length of the given string. Parameters string - the string being measured for length. Return Values - the length of the string on success, and 0 if the string is empty. Examples $str = 'abcdef'; echo strlen($str); // 6 $str = ' ab cd '; echo strlen($str); // 7 Note: 1. strlen() returns the number of bytes rather than the number of characters in a string. 2. strlen() returns NULL when executed on arrays, and an E_WARNING level error is emitted. str_word_count()— returns information about words used in a string Description mixed str_word_count ( string $string [, int $format = 0 [, string $charlist ]] ) Counts the number of words inside string. If the optional format is not specified, then the return value will be an integer representing the number of words found. In the event the format is specified, the return value will be an array, content of which is dependent on the format. Parameters string - the string format Specify the return value of this function. The current supported values are: 0 - returns the number of words found 1 - returns an array containing all the words found inside the string 2 - returns an associative array, where the key is the numeric position of the word inside the string and the value is the actual word itself chartist A list of additional characters which will be considered as 'word' Return Values - returns an array or an integer, depending on the format chosen. Examples 1. print_r(str_word_count($str, 1)); - returns an array containing all the words found inside the string 2.

    More about Php701 Essay

      Open Document