The strncasecmp() function is used to compare a case-sensitive string of the first ‘n’ character. This function was introduced in PHP4. The comparison is case-insensitive—that is, “Alphabet” and “alphabet” are considered equal. This function is a case-insensitive version of strcmp(). If either string is shorter than length characters, the length of that string determines how […]
PHP
PHP function strlen() – Get string length
The strlen() function is used to return the length of a specific string. This function was introduced in PHP3. The strlen() function takes just one parameter (the string) and returns the number of characters in it. Syntax: strlen(string $string): int Behind the scenes, strlen() actually counts the number of bytes in your string, as opposed […]
PHP function stripslashes() – Un-quotes a quoted string
The stripslashes() function is used to unquote a string that is quoted by using the addslashes() function. This function was introduced in PHP3. The stripslashes() function is the opposite of addslashes(): it removes one set of \-escapes from a string. Syntax: stripslashes(string $string): string To remove backslashes and convert C-style escape sequences to their literal […]
PHP function stripcslashes() – Un-quote string quoted with addcslashes()
stripcslashes() converts C-style escape sequences (\, \a, \b, \f, \n, \r, \t, \v, and \x hh hex and \ ooo octal character escape sequences) to their literal equivalents. Additionally, it strips the backslash from escape sequences that it doesn’t recognize. You can specify ranges of characters by separating them by two periods; for example, to […]
PHP function strcmp() – Binary safe string comparison
The strcmp() function is used to compare two case-sensitive strings. This function was introduced in PHP3. The function basically compares two strings; returns a number less than 0 if one is less than two, 0 if the two strings are equal, and a number greater than 0 if one is greater than two. The comparison […]
PHP Function strchr() – Alias of strstr()
The strchr() function is used to find the first appearance of a string inside another string. It is the pseudonym of the strstr() function. This function was introduced in PHP3. Syntax: strchr(string $haystack, string $needle, bool $before_needle = false): string|false For instance: $record = “Fred,Flintstone,35,Wilma”; $rest = strchr($record, “,”); // $rest is “,Flintstone,35,Wilma” The variations […]
PHP function strcasecmp() – Binary safe case-insensitive string comparison
The strcasecmp() function is used to compare two case-sensitive strings. This is a case-insensitive version of the strcmp(). This function was introduced in PHP3. The function returns a number less than 0 if one is less than two, 0 if the two strings are equal, and a number greater than 0 if one is greater […]
PHP Function str_word_count() – Return information about words used in a string
The str_word_count() function is used to count the number of words in a string. This function was introduced in PHP4. The value of format dictates the returned value: value returned value 0 (default) The number of words found in string 1 An array of all words found in string 2 An associative array, with keys […]
PHP Function str_split() – Convert a string to an array
The str_split() function is used to split a string into an array. This function was introduced in PHP5. The function splits the string into an array of characters, each containing length characters; if the length is not specified, it defaults to 1. Syntax: str_split(string $string, int $length = 1): array Parameters Parameter Description string The […]
PHP function str_replace() – Replace all occurrences of the search string with the replacement string
The str_replace() function is used to replace some case-sensitive characters in a string. This function was introduced in PHP3. The str_replace() function replaces parts of a string with new parts you specify and takes a minimum of three parameters: what to look for, what to replace it with, and the string to work with. If […]