1、php 截取特定字符后面的內容
可以使用函數strripos,獲取一個字符串在另一個字符串中第一次出現的位置。
$number = '1_0';
$result = substr($number,strripos($number,"_")+1);
echo $result;
該程式輸出0
2、php 截取特定字符前面的內容
可以使用函數strrops,獲取一個字符串在另一個字符串中最后一次出現的位置。
$test = '1_0';
$result = substr($test,0,strrpos($test,"_"));
echo $result;
該程式輸出1