从PHP中的字符串中删除特定字符 [英] Removing specific characters from a string in php

查看:103
本文介绍了从PHP中的字符串中删除特定字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我该如何检查php中的字符串以查找诸如'#'或'\'之类的特定字符?

How can I check a string in php for specific characters such as '#' or '\'?

我真的不想使用replace,只是返回true或false。

I don't really want to use replace, just return true or false.

谢谢

推荐答案

使用该函数strstr http://us2.php.net/manual/en/function.strstr .php
返回从第一次出现针到干草堆结束的部分干草堆字符串

use the function strstr http://us2.php.net/manual/en/function.strstr.php Returns part of haystack string from the first occurrence of needle to the end of haystack

注意:如果您只想确定是否特定的针头发生在干草堆中,请改用速度更快且占用较少内存的函数strpos()。

Note: If you only want to determine if a particular needle occurs within haystack , use the faster and less memory intensive function strpos() instead.

这篇关于从PHP中的字符串中删除特定字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆