如何在PHP中最后一个逗号后删除字符串的一部分 [英] How to remove part of a string after last comma in PHP
本文介绍了如何在PHP中最后一个逗号后删除字符串的一部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在PHP中最后一个逗号后删除字符串的一部分?
How to remove part of a string after last comma in PHP ?
字符串:"this is a post, number 1, date 23, month 04, year 2012"
预期:"this is a post, number 1, date 23, month 04"
String : "this is a post, number 1, date 23, month 04, year 2012"
Expected: "this is a post, number 1, date 23, month 04"
推荐答案
$until = substr($string, 0, strrpos($string.",", ","));
注意:根据下面的评论进行编辑
Note: edited based on comments below
这篇关于如何在PHP中最后一个逗号后删除字符串的一部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文