Re: greedy preg
| From: | Kevin Stone | Date: | Wed, 06 Aug 2003 21:34:15 +0000 |
| Subject: | Re: greedy preg | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-158566@lists.php.net to get a copy of this message | ||
----- Original Message -----
From: "skate" <root@fatcuban.com>
To: <php-general@lists.php.net>
Sent: Wednesday, August 06, 2003 3:16 PM
Subject: [PHP] greedy preg
>
> $contents = preg_replace( "|<item>.*?$file.*?</item>|si", "",
$contents );
>
> it's being run on an XML file, where each entry is <item>......</item>
with
> a $file pointer in there.
>
> it works okay, except for the fact that it deletes that record, and every
> record before it. i can't figure out why it's being greedy? i know i gotta
> be missing something real simple...
You cannot store file pointers. If you output the variable it's going to
look something like "Resource ID #1" which is meaningless except to the
instance of the script that created it. Or did you mean something different
by "$file pointer"?
- Kevin