FUNCTION NAME |
FUNCTION DESCRIPTION |
FUNCTION SYNTAX |
FUNCTION RETURN VALUE |
substr_count()
[Count the number of substring occurrences] |
This function returns the number [‘count’] of times the needle substring occurs in the haystack string. needle is case-sensitive. |
substr_count(haystack, needle, offset [optional parameter with a default value of 0], length [optional parameter]);
[offset specifies the position at which to start counting. If negative, the comparison begins at offset characters from the end of the string. length specifies the maximum length after offset to search for the needle. A WARNING is output if offset plus length is greater than the haystack length. A negative length counts from the end of haystack.] |
substr_count() : returns an integer representation of the number of occurrences of needle within haystack. |
substr_replace()
[Replace text within a portion of a string] |
This function replaces a copy of string delimited by the start and optional length parameters [thus, a ‘substring’] with the replacement string. |
substr_replace(string, replacement, start, length [optional parameter, with a default value of strlen(string) ]);
[string represents the input string. An array of strings can be provided; in this case, the replacements will occur on each string in turn. replacement, start, and length may be provided as either scalar values or as arrays (whereby the corresponding array element will be used for each input string).
replacement defines the replacement string.
If start is non-negative, the replacing will begin at the startth offset into string. If negative, the replacing will begin at the startth character from the end of string.
If length is given and non-negative, it represents the length of the portion of string which is to be replaced. If negative, length represents the number of characters from the end of string at which replacing will end. Its default value is strlen(string) . If length is 0, replacement will be inserted into string at the start offset.] |
substr_replace() : the result string is returned. If string is an array, then an array is returned. |
substr()
[Return part of a string] |
This function returns the portion [‘substring’] of string specified by the start and length parameters. |
substr(string, start, length [optional parameter]);
[string represents the input string; must be one character or longer.
If start is non-negative, the returned string will begin at the startth position in string counting from 0. If start is negative, the returned string will begin at the startth character from the end of string. If string is less than start characters long, FALSE will be returned.
If length is given and is positive, the string returned will contain at most length characters beginning from start. If length is negative, length characters will be omitted from the end of string. FALSE will be returned if start denotes the position of this truncation or beyond. An empty string will be returned if length is 0, FALSE, or NULL. If length is omitted, the substring starting from start till the end of string will be returned.] |
substr() : returns the extracted part of string [the ‘substring’]; FALSE on failure, or an empty string. |
trim()
[Strip whitespace (or other characters) from the beginning and end of a string] |
This function returns a string with whitespace stripped [‘trimmed’] from the beginning and end of string. If character_mask is unspecified, trim() will strip the following characters: an ordinary space; a tab; a new line; a carriage return; the NUL-byte; and the vertical tab. |
trim(string, character_mask [optional parameter, with a default value of “\t\n\r\0\x0B”]);
[Further characters can be specified in the character_mask parameter. With .., a range of characters can be specified.] |
trim() : returns the trimmed string. |
ucfirst()
[Make a string’s first character uppercase] |
This function returns a string with the first character of string capitalized [‘uppercased’], if that character is alphabetic. ‘Alphabetic’ is determined by the current locale; in the default C locale, characters such as umlaut-a will not be capitalized. |
ucfirst(string); |
ucfirst() : returns the resulting string, after its first character has been uppercased if it is suitably ‘alphabetic’. |
ucwords()
[Uppercase the first character of each word in a string] |
This function returns a string with the first character of each word in string capitalized [‘uppercased’], if that character is ‘alphabetic’. A ‘word’ is defined as any string of characters that is immediately after any character listed in the delimiters parameter. |
ucwords(string, delimiters [optional parameter, with a default value of " \t\r\n\f\v" ]);
[The optional delimiters parameter contains the word separator characters. By default these are: space; horizontal tab; carriage return; form-feed; newline; and vertical tab.] |
ucwords() : returns the modified string, after the first character of all words have been uppercased if suitably ‘alphabetic’. |
vfprintf()
[Write a formatted string to a stream] |
This function writes [‘prints’] a string produced according to format to the stream resource specified by handle. Operates as fprintf() but accepts an array of args, rather than a variable number of arguments. |
vfprintf(handle, format, args);
[See sprintf() for more details on the format directives. Possible type specifiers: % (a literal percentage character); b (treated as integer, presented as binary); c (treated as integer, presented as character with that ASCII value); d (treated as integer, presented as signed decimal number); e (treated as scientific notation); E (uppercase scientific notation); f (treated as a float, presented as locale-aware floating-point number); F (treated as a float, presented as non-locale-aware floating-point number); g (shorter of %e and %f); G (shorter of %E and %f); o (treated as an integer, presented as an octal number); s (treated and presented as a string); u (treated as integer, presented as unsigned decimal number); x (treated as integer, presented as lowercase hexadecimal number); and X (treated as integer, presented as uppercase hexadecimal number).] |
vfprintf() : returns the length of the outputted string. |
vprintf()
[Output a formatted string] |
This function displays [‘prints’] array values as a string formatted according to format. Operates as printf() but accepts an array of arguments, rather than a variable number of arguments. |
vprintf(format, args);
[See sprintf() for more details on the format directives. See vfprintf() for further information on the possible type specifiers.] |
vprintf() : returns the length of the outputted string. |
vsprintf()
[Return a formatted string] |
vsprintf() operates as sprintf() but accepts an array of arguments, rather than a variable number of arguments. |
vsprintf(format, args);
[See sprintf() for more details on the format directives. See vfprintf() for further information on the possible type specifiers.] |
vsprintf() : returns the array values as a string formatted according to format. |
wordwrap()
[Wraps a string to a given number of characters] |
This function wraps a string [‘word’] to a given number of characters using a string break character. |
wordwrap(string, width [optional parameter, default value = 75], break [optional parameter, default value = "\n" ], cut [optional parameter, default value = FALSE]);
[If cut is set to TRUE, the string is always wrapped at or before width. When FALSE, the function does not split the word even if it is wider than width.] |
wordwrap() : returns the given string [‘word’] wrapped at the specified length. |