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

Link to comment
Share on other sites

$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 />";
}

Link to comment
Share on other sites

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];
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.