是否有运算符来比较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>