FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » grep in php?
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: grep in php? [message #179409 is a reply to message #179408] Sat, 20 October 2012 10:30 Go to previous messageGo to previous message
Luuk is currently offline  Luuk
Messages: 329
Registered: September 2010
Karma:
Senior Member
On 20-10-2012 12:04, houghi wrote:
> I am looking how to do a grep in php. I have a variable(1) with very much
> random data.
>
> I want only to get lines that have certain words in it. As far as I can
> see preg_grep does not work, as the data isn't an array.
>

read the file contents into an array:
http://www.php.net/manual/en/function.file.php

> I could use (exec grep ...), but I rather not.
>
> I am looking for something that does:
> $result = grep("word_I_look_for",$result);
>
> (1)If it is easier, I can use a file instead of a variable.
>
> houghi
>
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Code "folding" in NetBeans IDE 7.2
Next Topic: Placement & Work Solution provider
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Thu Feb 20 10:11:17 GMT 2025

Total time taken to generate the page: 0.04520 seconds