php grep exec or system regex
How can I grep a pattern that can include spaces, commas etc using exec
or system
in PHP, and return one string separated by a comma each result. If needed, I can make use of awk or sed to separated by comma.
So for instance, if the pattern to se开发者_运维知识库arch is: hello worl
then return:
$result = 'hello world, hello worlds, hello worldy';
Any ideas will be appreciated. Thanks
Check out escapeshellarg()
and escapeshellcmd()
.
Edit:
Is this in just one file? If you're not searching across the system then just use the built-in functions, they'll be plenty fast.
精彩评论