PHP Mb_strripos Use

Source: Internet
Author: User

Mb_strripos
  • (PHP 4 >= 4.0.6, PHP 5, PHP 7)
  • Mb_strrpos-find position of last occurrence of a string in a string
  • mb_strripos-case insensitive to find where a string last appears in a string
Description
mb_strrpos(     $haystack,    $needle[,     $offset0[,     $encodingmb_internal_encoding()]]     )//Performs a multibyte safe strrpos() operation based on the number of characters. needle position is counted from //the beginning of haystack. First character's position is 0. Second character position is 1.//mb_strripos() 基于字符数执行一个多字节安全的 strripos() 操作。 needle 的位置是从 haystack 的开始进行统计的。 第一个字符的位置//是 0,第二个字符的位置是 1。 和 mb_strrpos() 不同的是,mb_strripos() 是大小写不敏感的。
Parametershaystack
    • The string being checked, for the last occurrence of needle
    • Finds the position where the needle last appears in this string.
Needle
    • The string to find in haystack.
    • Look for this string in haystack.
Offset
    • May is specified to begin searching a arbitrary number of characters into the string. Negative values would stop searching at a arbitrary point prior to the end of the string.
    • The location to start the search in haystack.
Encoding
    • The encoding parameter is the character encoding. If It is omitted, the internal character encoding value would be used.
    • The character encoding name used. If omitted, the internal encoding is used.
Return Values
    • Returns the numeric position of the last occurrence of needle in the haystack string. If needle is not found, it returns FALSE.
    • Returns the value of the last occurrence of needle in the string haystack. If needle is not found, it will return FALSE.
Example
<?php/*** Created by Phpstorm.* User:zhangrongxiang* DATE:2018/2/5* Time: The afternoon at 11:00am */$str="Life was short,i use PHP";$por=Mb_strripos( $str, "PHP", Ten );Echo $por.Php_eol; //20functionStartsWith( $haystack, $needle ){$res=false;    if ( Mb_strripos( $haystack, $needle, 0, "Utf-8" )===0 ){$res=true;}return $res;}functionEndsWith( $haystack, $needle ){$res=false;    $len=Mb_strlen( $haystack );    $pos=$len-Mb_strlen( $needle );    if ( Mb_strripos( $haystack, $needle, 0, "Utf-8" )===$pos ){$res=true;}return $res;}if (StartsWith( $str, "Life" ) ){//true    Echo "StartsWith ($str, Life) ".Php_eol;}if (StartsWith( $str, "PHP" ) ){Echo "StartsWith ($str, PHP) ".Php_eol;}Else{//false    Echo "No StartsWith ($str, PHP) ".Php_eol;}if (EndsWith( $str, "PHP" ) ){//true    Echo "EndsWith ($str, PHP) ".Php_eol;}if (EndsWith( $str, "Life" ) ){Echo "EndsWith ($str, Life) ".Php_eol;}Else{//false    Echo "No EndsWith ($str, Life) ".Php_eol;}
Article reference
    • http://php.net/manual/en/function.mb-strrpos.php
Reprint Annotated Source

PHP Mb_strripos Use

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.