PHP判断字符是否以xxx开头

5年以前  |  阅读数:875 次  |  编程语言:PHP 
function stringStartWith($str, $needle) {
    return strpos($str, $needle) === 0;
  }

如判断"love china"是否以love开头:

if  stringStartWith("love china","love")){
    // ok, yes
}

Copyright© 2013-2020

All Rights Reserved 京ICP备2023019179号-8