怎么把未知长度的字符串从末尾截掉指定的字串呢

WBOY
Release: 2016-06-13 11:17:45
Original
967 people have browsed it

如何把未知长度的字符串从末尾截掉指定的字串呢?
如:字串:沈阳市公安局电话 想截掉尾部的“电话”,如何实现呢?

php字符串截取
------解决方案--------------------
$s='沈阳市公安局电话';
echo preg_replace('/电话$/','',$s);
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!