Brandon Jaeger Posted October 4, 2008 Share Posted October 4, 2008 How would I get the value inside of this tag? {INCLUDE:page.php} Thanks, Brandon Edit: Is it something like \{INCLUDE:^(.)$\}? Quote Link to comment Share on other sites More sharing options...
JasonLewis Posted October 4, 2008 Share Posted October 4, 2008 Try this: $str = "{INCLUDE:page.php}"; preg_match("#{INCLUDE:(.*?)}#is", $str, $matches); echo $matches[1]; Quote Link to comment Share on other sites More sharing options...
Brandon Jaeger Posted October 4, 2008 Author Share Posted October 4, 2008 I love you <3 Quote Link to comment Share on other sites More sharing options...
Brandon Jaeger Posted October 4, 2008 Author Share Posted October 4, 2008 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 Quote Link to comment Share on other sites More sharing options...
JasonLewis Posted October 4, 2008 Share Posted October 4, 2008 $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 />"; } Quote Link to comment Share on other sites More sharing options...
Brandon Jaeger Posted October 4, 2008 Author Share Posted October 4, 2008 Thanks! Quote Link to comment Share on other sites More sharing options...
ghostdog74 Posted October 6, 2008 Share Posted October 6, 2008 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]; } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.