Jump to content

[SOLVED] Get value inside tag


Brandon Jaeger

Recommended Posts

Actually... How would I detect all of the matches within a string? I seem to be having trouble with this. I tried it with preg_match_all as well and it didn't work.

 

	$str = "This {INCLUDE:page_01.php} is {INCLUDE:page_02.php} some {INCLUDE:page_03.php} text";

if(preg_match("#{INCLUDE:(.*?)}#is", $str, $matches))
{
	$numMatches = count($matches);

	echo '# of matches: ' . $numMatches . '<br \>';

	for($i = 1; $i <= $numMatches; $i++)
		echo $matches[$i] . '<br \>';
}

Thanks

$str = "This {INCLUDE:page_01.php} is {INCLUDE:page_02.php} some {INCLUDE:page_03.php} text";
preg_match_all("#{INCLUDE:(.*?)}#is", $str, $matches);

echo "Total Matches: " . count($matches[1]) . "<br />";

foreach($matches[1] as $match){
echo $match."<br />";
}

How would I get the value inside of this tag?

 

{INCLUDE:page.php}

 

Thanks,

Brandon

 

Edit: Is it something like \{INCLUDE:^(.)$\}?

$string = "{INCLUDE:page.php}";
if ( stripos($string,"{INCLUDE" ) !==FALSE ){
    $result=split(":|}",$string);
    echo $result[1];
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.