PHP Simple to judge whether a string contains another string method, PHP string _php Tutorial

Source: Internet
Author: User
Tags getting started with php php regular expression

Php Simple method to determine whether a string contains another string, PHP string


This article describes a simple way for PHP to determine whether a string contains another string. Share to everyone for your reference, as follows:

When using PHP to determine if a string contains a simple substring, we usually use Strpos () or stristr (), but it happens that if the position of the string is at index 0, that is, at the beginning of the string to be matched, there will be a problem.

Of course, we still have a solution, there is a stupid way, but more useful, both in English, punctuation is applicable.

The code is as follows:

function Checkstr ($STR, $target) {  $TMPARR = explode ($str, $target);  Print_r ($TMPARR);  if (count ($TMPARR) >1) return true;  else return false;} $result = Checkstr ("SDFG", "BSDFSLDKFJ"); Var_dump ($result);

More readers interested in PHP related content can view this site topic: "PHP Operations Office Document Tips summary (including word,excel,access,ppt)", "PHP date and Time usage summary", "PHP Object-oriented Programming tutorial", "PHP string (string) Usage summary, "Getting Started with Php+mysql database operation" and "PHP common database Operation Skills Summary"

I hope this article is helpful to you in PHP programming.

Articles you may be interested in:

    • PHP determines if the string contains HTML tags
    • PHP-Judging characters and string-containing method properties
    • A method in PHP that determines whether a string contains another string
    • PHP check whether the string contains 7-bit GSM characters in the method
    • PHP function sharing for intercepting strings containing HTML tags
    • PHP strstr Lookup function to find if a string contains some characters
    • PHP Regular expression that does not contain a string
    • Php Simple method to determine whether two strings are equal
    • PHP determines whether a string is a method of returning literal strings
    • Php method for determining if a string exists in an array element
    • Php method for judging string position in another string
    • PHP strstr function to determine whether a string is not present in the instance code
    • PHP to determine whether the string is all Chinese or contains Chinese implementation code

http://www.bkjia.com/PHPjc/1113698.html www.bkjia.com true http://www.bkjia.com/PHPjc/1113698.html techarticle PHP Simple to determine whether a string contains another string method, PHP string This article describes the PHP simple to determine whether the string contains another string method. To share with you ...

  • Related Article

    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.