PHP 字符串截取

PHP    substr        strpos

JAVA  subString   indexof

PHP:

    $pos=strpos("12345", "3");
    $substring=substr("12345", 0,$pos);
    echo $substring;

输出:
12

JAVA:

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

输出:
12

  

原文地址:https://www.cnblogs.com/frostbelt/p/2159096.html