PHP checks whether a string exists in the string.

Source: Internet
Author: User

First look at the following function:

 

String processing function library

Strpos

Searches for the first occurrence of a character in a string.

Syntax: Int strpos (string haystack, string needle, int [offset]);

Return Value:Integer

Function types:Data Processing

 

Description

This function is used to find the first position where the character needle in the haystack string appears. It is worth noting that the needle can only be one character, and it is not suitable for Chinese characters. If the specified character is not found, false is returned. The offset parameter can be omitted, which is used to start searching from offset.

 

Reference

Strrpos () strrchr () substr ()
Strstr ()

If the returned location exists, false is returned if the returned location does not exist. Therefore, this can be determined: $ is_exist = is_int (strpos ('Hello the world! ', 'Hello ));

First look at the following function:

 

String processing function library

Strpos

Searches for the first occurrence of a character in a string.

Syntax: Int strpos (string haystack, string needle, int [offset]);

Return Value:Integer

Function types:Data Processing

 

Description

This function is used to find the first position where the character needle in the haystack string appears. It is worth noting that the needle can only be one character, and it is not suitable for Chinese characters. If the specified character is not found, false is returned. The offset parameter can be omitted, which is used to start searching from offset.

 

Reference

Strrpos () strrchr () substr ()
Strstr ()

If the returned location exists, false is returned if the returned location does not exist. Therefore, this can be determined: $ is_exist = is_int (strpos ('Hello the world! ', 'Hello ));

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.