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

原文链接:https://www.cnblogs.com/zhengdongdong/p/9603382.html

相关文章:

  • 2022-12-23
  • 2021-07-24
  • 2022-12-23
  • 2022-12-23
  • 2022-02-09
  • 2021-09-05
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-11-17
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案