Webmaster
| |
| eval(php_code_string) | |
| Allows you to have the string passed to the function to be evaluated in the same way as regular PHP code. | |
| Example | <? eval('$value = 8;'); print($value); ?> |
| sprintf(format, mixed_arguments) | |
| Same as printf except that it lets you place the formatted output in a string variable whereas printf outputs it to the screen and returns a status value only. Format is a string made up of simple characters and optional conversion codes and placeholders. Mixed_arguments is an optional comma separated list of values or variables you want to output. | |
| Example | printf("Character string with conversion codes and placeholders."); |
| strcasecmp(chaîne1, chaîne2) | |
| Same as strcmp, except that case distinction is ignored. | |
| Example | <? $uno = "abc"; $dos = "aBc"; strcasecmp($uno, $dos) ?> |
| strcmp(string1, string2) | |
| This function compares the two strings passed as arguments and returns: 0 if they are equal and either a positive or a negative number, depending on whether the first string is greater or less than the second one. | |
| Example | <? $uno = "abc"; $dos = "aBc"; strcmp($uno, $dos) ?> |
| strcspn(string1, string2) | |
| This function returns the number of characters at the beginning of the first argument (string1) that are not present in the second argument (string2). | |
| Example | <? $string = "The companions"; $chargroup = "abc"; strcspn($string, $chargroup); ?> |
| strlen(string) | |
| Returns the length of the string passed as argument. | |
| Example | <? print(strlen("A character string")); ?> |
| strpos(string, pattern) | |
| Returns the position of the first occurrence of the second argument (pattern), found in the first argument (string). Note that other occurrences of the pattern found in the searched string will be ignored. And if the pattern is not a string, it will be converted in an integer and applied as a character's ASCII code value. | |
| Example | <? $string = "What a fabulous fable"; strpos($pattern, "fab"); ?> |
| strrpos(string, pattern_char) | |
| Searches the first argument for the character passed as the second argument, and returns the position of the last occurrence of the character. | |
| Example | <? $string = "great great life"; strrpos($string, "g"); ?> |
| strspn(string, pattern) | |
| Returns the length of the initial segment in the first argument (string) that consists entirely of characters contained in the second argument (pattern). | |
| Example | <? $string = "balcony"; $chargroup = "abc"; $pointer = strspn($string, $chargroup); ?> |
| strstr(string, pattern) | |
| Searches for the second argument (pattern) in the first argument (string), and returns all of the latter from the first occurrence of the pattern to the end. As in other string functions, if the pattern is not a string, it is converted into an integer and is applied as a character's ASCII code value. | |
| Example | <? $string = "Here is a character string, and the segment to be kept."; strstr($string, ","); ?> |
| strtok(string, delimiter) | |
| Breaks down into pieces the string passed as the first argument, using the delimiter passed as the second argument. | |
| Example | <? $address = "franck\tarthur\tfranck@mysite.com"; for($pieces = strtok($address, "\t"); $pieces != ""; $pieces = strtok("\t")) ?> |
| substr(string, start, length) | |
| Returns a segment of the string passed as the first argument, starting at the position defined by the second argument. This position is calculated by counting the number of characters the argument represents from the beginning of the searched string, using a zero-based count. For instance, the returned portion would begin with the second character if the second argument's value was 1. You can also use a negative number as the starting position, in which case the character count starts from the end of the searched string. If no value is passed as the third argument (length), the entire searched string is returned from the specified position to the end. If given, the length can also be a negative value, in which case it represents the number of characters counted from the string end to be excluded from the portion returned by the function. |
|
| Example | <? $string = "My name is Francky."; print(substr($string, 12, 7)); ?> |
| |