Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #7341 > unrolled thread
| Started by | houghi <houghi@houghi.org.invalid> |
|---|---|
| First post | 2012-10-20 12:04 +0200 |
| Last post | 2012-10-20 15:07 +0200 |
| Articles | 3 — 2 participants |
Back to article view | Back to comp.lang.php
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
| From | houghi <houghi@houghi.org.invalid> |
|---|---|
| Date | 2012-10-20 12:04 +0200 |
| Subject | grep in php? |
| Message-ID | <slrnk84tpi.3ht.houghi@penne.houghi> |
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.
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
--
I do not want life insurance.
I want all people to be genuinely grieving when I die.
houghi
[toc] | [next] | [standalone]
| From | Luuk <luuk@invalid.lan> |
|---|---|
| Date | 2012-10-20 12:30 +0200 |
| Message-ID | <i2bal9-2q8.ln1@luuk.invalid.lan> |
| In reply to | #7341 |
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
>
[toc] | [prev] | [next] | [standalone]
| From | houghi <houghi@houghi.org.invalid> |
|---|---|
| Date | 2012-10-20 15:07 +0200 |
| Message-ID | <slrnk858gd.3ht.houghi@penne.houghi> |
| In reply to | #7342 |
Luuk wrote: > 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 OK, thanks for the pointer. houghi -- I do not want life insurance. I want all people to be genuinely grieving when I die. houghi
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.php
csiph-web