How to Use the PHP stristr () function for character search

Source: Internet
Author: User

Through

PHP stristr () function -- finds the position of the string that appears for the first time in another string.

Define and use the PHP stristr () function to find the position where the string first appears in another string. If successful, the rest of the string is returned (from the matching point ). If this string is not found, false is returned.

Syntax stristr (string, search)

Parameters and descriptions
String is required. Specifies the string to be searched.
Find is required. Specifies the characters to be searched. If this parameter is a number, search for characters matching the ASCII value of the number.

Tip and comment: this function is binary secure.
Note: This function is case insensitive. Use strstr () for case-sensitive searches ().

Example 1 of the PHP stristr () function

 
 
  1. <? Php
  2. Echo stristr ("Hello world! "," WORLD ");
  3.  
  4. ?>

Output:

World!

PHP stristr () function Example 2

 
 
  1. <? Php
  2. Echo stristr ("Hello world! ", 111 );
  3. ?>
  4.  

Output:

O world!


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.