php 字符串截取

PHP substr strpos

    $pos=strpos("12345", "3");
    $substring=substr("12345", 0,$pos);
    echo $substring;
 
输出:
12

JAVA subString indexof

    String str="12345";
    int pos=str.indexOf("3");
    String substring=str.substring(0, pos);
    System.out.println(substring);
 
输出:
12

PHP 从最末一个"_"开始截取:

	$str="s_s_s";
	$pos=strrpos($str,"_");
	$substring=substr($str,$pos+1);
	echo $substring;

输出:
s
原文地址:https://www.cnblogs.com/frostbelt/p/2388757.html