Re: Newb Question - find and record
| From: | David Duong | Date: | Wed, 08 May 2002 22:34:54 +0000 |
| Subject: | Re: Newb Question - find and record | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-96696@lists.php.net to get a copy of this message | ||
I know the first part. (I thought maybe their was a function that can be
used in conjunction with matching.)
This is what I am looking at.
preg_match_all ("|<[^>]+>(.*)</[^>]+>|U",
"<b>example: </b><div align=left>this is a test</div>",
$out, PREG_PATTERN_ORDER);
print $out[0][0].", ".$out[0][1]."\n";
print $out[1][0].", ".$out[1][1]."\n"
The only part that confuses me is the [^>]. How would you have it search
only for Test tags?.
This:
preg_match_all ("|<test+>(.*)</test+>|U",
"<b>example: </b><test>this is a test</test>",
$out, PREG_PATTERN_ORDER);
print $out[0][0].", ".$out[0][1]."\n";
print $out[1][0].", ".$out[1][1]."\n"
prints out:
Warning: Undefined offset: 1 in
C:\WINDOWS\DESKTOP\DAVID'~1\PROJECTS\SNR\phpF071.PHP
on line 7
this is a test,
Warning: Undefined offset: 1 in
C:\WINDOWS\DESKTOP\DAVID'~1\PROJECTS\SNR\phpF071.PHP
on line 8
this is a test,
What is the error?
"Martin Towell" <martin.towell@world.net> wrote in message
news:6416776FCC55D511BC4E0090274EFEF508A2C8@exchange.world.net...
> use opendir(), readdir() and closedir() to find all the files
>
> use
> $fd = fopen ($filename, "r");
> $contents = fread ($fd, filesize ($filename));
> fclose ($fd);
> to read in the file
>
> use ereg() or preg_match() to find the text (for ereg(), use something
like
> "<test>(.*)</test>" - this isn't tested though)
>
> Use that as a starting point
> HTH
> Martin
>
> -----Original Message-----
> From: David Duong [mailto:davidduong1@hotmail.com]
> Sent: Wednesday, May 08, 2002 2:05 PM
> To: php-general@lists.php.net
> Subject: [PHP] Newb Question - find and record
>
>
> How would I open every file with a *.htm extension in a directory and
search
> for <test> have everything found between <test>...</test> tags placed in
an
> array?
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php