Prototype: Char *STRRCHR (const char *STR, char c);#include Find a character C in another string str in the last occurrence of the position (that is, starting from the right of STR to find the first occurrence of the character C), and return from
defined () function
Definition and usage
The defined () function checks to see if a constant exists.Returns true if the constant exists, otherwise false is returned.Example:
Define ("greeting", "Hello world!");echo defined ("greeting");?>Output:1
In a longer string this finds matching strings or characters, where STRSTR () and STRCHR () are exactly the same.Cases:echo strstr (' Why all you ', ' you ');Output:YouIf you are:echo strstr (' Why all you ', ' you ');Then no outputThe Stristr ()
PHP strstr, STRRCHR, substr, stristr Four functional usage differences:
PHP strstr STRRCHR substr stristr These four string manipulation functions are especially confusing, often substr,strstr, which can basically satisfy the operation of the
In php, The strstr, strpos, substr, strrchr, and stripos functions are usually used to find out whether a character exists in a string. If you need to know about them, please refer to them.
1. strstr-first appearance of the search string
String
Prototype:char *strrchr (const char *STR, char c);#include Find a character C in another string str in the last occurrence of the position (that is, from the right of STR to find the first occurrence of the character C position). If the specified
Finding another string in a string can use either Strstr (), STRCHR (), STRRCHR (), STRISTR () four functions.
The function strstr () is the most common, and the function prototype is:
Strstr (String,search,before_search)//string the string to be
Describes and uses the following four functions related to strings in php: substr, strrchr, strstr, and ereg. 1. obtain some strings. Copy the code as follows: stringsubstr (stringstring, intstart, int [length]); this function extracts the string
Char *strchr (const char *s, int c)Function: Find the position of the first C character in the string s
Description: Returns a pointer to the position of the first occurrence of C, the returned address is the first pointer to the string that is
This article mainly introduces four functions and examples of using strings in php. For more information, see
1. obtain some strings.
The code is as follows: string substr (string, int start, int [length]);
This function extracts the start
Implement STRRCHR (find where the string last occurred) #include #include char * MY_STRRCHR (char const *STR, char C {int count = 0;int I;assert (str! = NULL); while (*str! = ') {str++;count++;} Str--;for (i = 0; i If you look for n, the
The strrchr () function finds the position of the last occurrence of a string in another string, and returns all characters from this position to the end of the string.
Otherwise, false is returned.
SyntaxStrrchr (string, char) parameter
One, take partial string.
Copy Code code as follows:
String substr (string string, int start, int [length]);
This function extracts the length character of the string from the start of string strings. If start is a negative number,
/* Strchr */ /* This function is used to locate the first occurrence of a character in a string. */ /* If it is found, the absolute address is returned. If it is not found, null is returned. */ Char * /* Returns the absolute position of
Strcat
A simple strcat, I in the actual coding, or found the problem, first list
1. Mainly in Strcat_m, the beginning of Line8,while (tmp++!= ' ") and the following line9 is not the same.
Line8: After TMP points to ' "," and then shift back to a
The CHR function is used to convert an ASCII code to a character, the Ord function is used to convert a character to ASCII ASCII code that is the computer can display the character encoding, its value range is 0-255, including punctuation, letters,
A self-made small website always has a question about one of its functions. could you please help me? One. php: (entry to start running) & lt ;? Php/** & nbsp; * & nbsp; index. php & nbsp; MyLocalShop & nbsp; Portal & nbsp; * & nbs makes a small
A self-made small website always has a question about one of its functions. could you please help me? One. php: (entry to start running) & lt ;? Php ** & nbsp; * & nbsp; index. php & nbsp; MyLocalShop & nbsp; Portal & nbsp; * & nbsp; @ copyright (C)
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.