是否有运算符来比较PHP中的相似性? [英] Is there an operator to compare likeness in PHP?

查看:95
本文介绍了是否有运算符来比较PHP中的相似性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正如你在MySQL中看到的那样,有一个LIKE =''%something%''"


我想知道在PHP中是否有办法做到这一点?


谢谢:)

As you see in MySQL there is the "LIKE =''%something%''"

I was wondering if there was a way to do this within PHP?

Thanks :)

推荐答案

最接近的是strstr(),用于搜索字符串中的字符串
The closest is strstr() which searches for a string within a string



最接近的是strstr(),它搜索字符串中的字符串
The closest is strstr() which searches for a string within a string



I认为一个更好的功能是 preg_match()!唯一需要注意的是,您需要使用正则表达式。

I think a much nicer function to try is preg_match()! The only caveat is that you will need to use regular expressions.


除非您需要,否则不要使用正则表达式。正则表达式需要更长时间才能运行并消耗更多内存。我今天早些时候回复了一个关于这个问题的回忆,你可以看到我的测试结果< LINK REMOVED>
Don''t use regular expressions unless you need them. Regular expression take longer to run and use up more memory. I just replied to a convo about this earlier today, you can see my test results <LINK REMOVED>


这篇关于是否有运算符来比较PHP中的相似性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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