int strlen ( string $string ) string strtr ( string $str, string $from, string $to ) string strtr ( string $str, array $replace_pairs ) int strcmp ( string $str1, string $str2 ) int strcasecmp ( string $str1, string $str2 ) Note: PHP first transparently converts strings to their numeric equivalent; use “===” in the IF logicint strpos ( string $haystack, mixed $needle [, int $offset] ) int stripos ( string $haystack, string $needle [, int $offset] ) int strrpos ( string $haystack, string $needle [, int $offset] ) string strstr ( string $haystack, string $needle ) string stristr ( string $haystack, string $needle ) int strspn ( string $str1, string $str2 [, int $start [, int $length]] )whitelistint strcspn ( string $str1, string $str2 [, int $start [, int $length]] )blacklist mixed str_replace ( mixed $search, mixed $replace, mixed $subject [, int &$count] ) mixed str_ireplace ( mixed $search, mixed $replace, mixed $subject [, int &$count] ) mixed substr_replace ( mixed $string, string $replacement, int $start [, int $length] )The result string is returned. If string is an array then array is returned string substr ( string $string, int $start [, int $length] ) string number_format ( float $number [, int $decimals [, string $dec_point, string $thousands_sep]] ) not locale-awarestring money_format ( string $format, float $number ) locale aware The money_format() function is not available onWindows, as well as on some variants of UNIX.string setlocale ( int $category, string $locale [, string $…] ) string setlocale ( int $category, array $locale ) Printf Family print(), sprintf(), vprintf(), sscanf(), fscanf()——————————————————————————————————** int printf ( string $format [, mixed $args [, mixed $…]] ) commonly-used type specifiers:****% - a literal percent character. No argument is required. b - the argument is treated as an integer, and presented as a binary number. c - the argument is treated as an integer, and presented as the character with that ASCII value. d - the argument is treated as an integer, and presented as a (signed) decimal number. e - the argument is treated as scientific notation (e.g. 1.2e+2). u - the argument is treated as an integer, and presented as an unsigned decimal number. f - the argument is treated as a float, and presented as a floating-point number (locale aware). F - the argument is treated as a float, and presented as a floating-point number (non-locale aware). Available since PHP 4.3.10 and PHP 5.0.3. o - the argument is treated as an integer, and presented as an octal number. s - the argument is treated as and presented as a string. x - the argument is treated as an integer and presented as a hexadecimal number (with lowercase letters). X - the argument is treated as an integer and presented as a hexadecimal number (with uppercase letters). Perl-compatible Regular Expressions Delimiters By convention, the forward slash is used **Metacharacters \d Digits 0-9 \D Anything not a digit \w Any alphanumeric character or an underscore (_) \W Anything not an alphanumeric character or an underscore \s Any whitespace (spaces, tabs, newlines) \S Any non-whitespace character . Any character except for a newline Quantifiers ? Occurs 0 or 1 time * Occurs 0 or more times
- Occurs 1 or more times {n} Occurs exactly n times {,n} Occurs at most n times {m,} Occurs m or more times {m,n} Occurs between m and n times Sub-Expressions** compare this to the “range” e.g. [1-9]PCRE – Pattern Modifiers – i – Case insensitive search – m – Multiline, $ and ^ will match at newlines – s – Makes the dot metacharacter match newlines – x – Allows for commenting – U – Makes the engine un-greedy – u – Turns on UTF8 support – e – Matched with preg_replace() allows you to callFunctions: int preg_match ( string $pattern, string $subject [, array &$matches [, int $flags [, int $offset]]] )***If matches is provided, then it is filled with the results of search. $matches[0] will contain the text that matched the full pattern, $matches[1] will have the text that matched the first captured parenthesized subpattern, and so on.*int preg_match_all ( string $pattern, string $subject, array &$matches [, int $flags [, int $offset]] ) **mixed preg_replace ( mixed $pattern, mixed $replacement, mixed $subject [, int $limit [, int &$count]] )**to reuse captured subpatterns directly in the substitution string by prefixing their index with a dollar sign Just like with str_replace(), we can pass arrays of search and replacement arguments; however, unlike str_replace(), we can also pass in an array of subjects on which to perform the search-and-replace operation. This can speed things up considerably, since the regular expression (or expressions) are compiled once and reused multiple times.