Home  >  Article  >  Backend Development  >  php中判断字符串肇端和结束

php中判断字符串肇端和结束

WBOY
WBOYOriginal
2016-06-13 13:03:571026browse

php中判断字符串开头和结束
    $str="/*zone adlidi lkdjoaihdn laidfhoh k23980ejnml ll;i;*/"
//判断字符串是否以“/*”开头
     if (preg_match("/^\/\*/",$str)){
     echo "true";
     }else{
     echo "false";
     }
//判断字符串是否以“/*”结束   
     if (preg_match("/\*\/$/",$str)){
     echo "true";
     }else{
     echo "false";
     }

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn