zhengdongdong

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

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2021-11-13
  • 2022-12-23
  • 2021-11-15
  • 2021-11-27
  • 2022-12-23
猜你喜欢
  • 2021-11-17
  • 2021-11-27
  • 2022-12-23
相关资源
相似解决方案