String Functions Flashcards
sprintf( string $format [, mixed $args] )
Returns a string formatted according to the conversion specifier used, which applies to $args.
strlen( string $subject )
Returns an integer representing the number of characters in string $subject
printf( string $format [, mixed $args] )
Just like sprintf(), except it prints the output directly to the output buffer rather than returning it for encapsulation in a var
str_pad( string $input, int $length, [, string $padding [, int $pad_type]] )
Returns the $input padded with enough spaces so that the total strlen is $length.
By default, a space character is used as the pad. Specify any other char with the $padding arg.
By default, padding is added to the end of the $input. This can be changed with the $pad_type arg.
strtolower( string $subject )
Returns a copy of $subject with all characters lowercased
strtoupper( string $subject )
Returns a copy of $subject with all characters uppercased
ucfirst( string $subject )
Returns a copy of $subject with only the first character of the first word capitalized
ucwords( string $subject )
Returns a copy of $subject with the first letter of every word capitalized
ltrim( string $subject [, string $character_list])
Returns a copy of $subject without leading white space (or $character_list).
$character_list can be a range by using ..
rtrim( string $subject [, string $character_list] )
Returns a copy of $subject without trailing white space (or $character_list)
$character_list can be a range by using ..
trim( string $subject [, string $character_list] )
Removes any white space (or $character_list) from in front if and behind $subject.
$character_list can be a range using ..
strcmp( string $str1, string $str2 )
Provides a more robust solution than == for comparing strings with binary content or multi-byte encoding.
Returns 0 if $str1 and $str2 are equal
Returns -1 if $str1 is alphabetically higher than $str2
Returns 1 if $str1 is alphabetically lower than $str2
Capitalized characters are considered alphabetically higher than their lowercased equivalent.
strncmp( string $str1, string $str2, int $length )
Like strcmp() except the $length argument specifies how much of each string is compared.
If $length = 4, then only the first 4 characters of $str1 and $str2 are compared.
strcasecmp( string $str1, string $str2 )
Just like strcmp() except case-insensitive.
strncasecmp( string $str1, string $str2, int $length )
Just like strncmp() except case-insensitive.