Forum Moderators: coopster

Message Too Old, No Replies

Using the "include" function

I know it can be more specific but....

         

HeyJim

2:51 pm on Jun 4, 2004 (gmt 0)

10+ Year Member



I can use
<?
@Include'http://somedomain.com/test.htm';
?>
and include the entire contents of a page in the middle of the page carrying the this code but I can't figure out how to specify only copy part of the page contents from "widget" to "arbuckle" (for instance).

What is the solution to this, please. And, thanks!

WhosAWhata

3:40 am on Jun 5, 2004 (gmt 0)

10+ Year Member



you want to do something like
<?
$pagecontents = file_get_contents("mypage.php");
$start = "widget";
$end = "arbuckle";
if(!preg("$start(.*)$end",$pagecontents,$match) {
$match = "NO MATCH";
}
echo $match;

i think i have the wrong syntax on the preg, but i'm not sure

WhosAWhata

5:34 am on Jun 5, 2004 (gmt 0)

10+ Year Member



actually i think it is preg_match instead of preg, i can't quite remember

mykel79

10:55 am on Jun 5, 2004 (gmt 0)

10+ Year Member



I believe you will have to do
echo $match[1]

since preg_match returns parenthesized subpatterns in an array. Here there is only one subpatern in parenthesis, so it will be in $match[1]

HeyJim

12:43 pm on Jun 5, 2004 (gmt 0)

10+ Year Member



Thanks everyone. Got it.