you dont need to use preg_split in this case, theres no regular expression involved
just use explode(). faster, simpler.
your code wasnt working because your using a variable named $match, which doesnt exist
fix that and it would work.
Code: Select all
<?php
$subject = file_get_contents ("mypage.html");
$pattern ="/include ?\('.*'\)/";
preg_match_all ($pattern, $subject, $matches);
foreach ($matches[0] as $match) {
$parts = explode("'", $match);
echo $parts[1] . '<br>';
}
?>
when i told you before it is difficult to isolate the filename that was so because i was taking into the possibility that you may use single or double quotes in the include staement, and may or may not use parenthesis
like
include "foo.php";
but if your syntax is always the same, you could just use this pattern
and then theres no need to use explode or anything
Code: Select all
$pattern = "/include ?\('([^']+)'\)/";
preg_match_all ($pattern, $subject, $matches);
print_r($matches);
oh and preg_* functions are all PCRE
ereg* functions are NOT
thats how to tell the diff. p means perl
pcre = perl compatible regular expression
btw- if you havent seen this site, take a look. i found this place very helpful
http://www.regular-expressions.info/tutorial.html