PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
Mr Tech
Forum Contributor
Posts: 424 Joined: Tue Aug 10, 2004 3:08 am
Post
by Mr Tech » Wed Sep 15, 2004 9:02 pm
Hey there!
I'm using the preg_match() function to retreieve information from a file. This is an example of the file:
Code: Select all
<?php
$title = <<<EOF
Title goes here
EOF;
$body = <<<EOF
Content goes here
EOF;
?>
Now when I use this query:
Code: Select all
<?php
if( preg_match( "/title = <<<EOF([^\|]*)EOF;/is", $content, $match ) )
$title = $match[1];
?>
It get the content from the $title all the way down to the end of the $body tag when I only want the $title. I tried ([^\EOF;]*) but it didn't work...
Any suggestions?
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Wed Sep 15, 2004 11:14 pm
Mr Tech
Forum Contributor
Posts: 424 Joined: Tue Aug 10, 2004 3:08 am
Post
by Mr Tech » Wed Sep 15, 2004 11:34 pm
Awesome works well! Also, it it possible to remove this part: [^\|] so it's like (*?) I tried it but it didn't work because I don't want it to not work if there is a | in the text...
Thanks again!
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Wed Sep 15, 2004 11:39 pm
Mr Tech
Forum Contributor
Posts: 424 Joined: Tue Aug 10, 2004 3:08 am
Post
by Mr Tech » Wed Sep 15, 2004 11:46 pm
Thanks, will do.