Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #7342

Re: grep in php?

Date 2012-10-20 12:30 +0200
From Luuk <luuk@invalid.lan>
Newsgroups comp.lang.php
Subject Re: grep in php?
References <slrnk84tpi.3ht.houghi@penne.houghi>
Message-ID <i2bal9-2q8.ln1@luuk.invalid.lan> (permalink)

Show all headers | View raw


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
>

Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

grep in php? houghi <houghi@houghi.org.invalid> - 2012-10-20 12:04 +0200
  Re: grep in php? Luuk <luuk@invalid.lan> - 2012-10-20 12:30 +0200
    Re: grep in php? houghi <houghi@houghi.org.invalid> - 2012-10-20 15:07 +0200

csiph-web