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:^(.)$\}? Link to comment https://forums.phpfreaks.com/topic/126972-solved-get-value-inside-tag/ 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]; Link to comment https://forums.phpfreaks.com/topic/126972-solved-get-value-inside-tag/#findComment-656819 Share on other sites More sharing options...
Brandon Jaeger Posted October 4, 2008 Author Share Posted October 4, 2008 I love you <3 Link to comment https://forums.phpfreaks.com/topic/126972-solved-get-value-inside-tag/#findComment-656821 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 Link to comment https://forums.phpfreaks.com/topic/126972-solved-get-value-inside-tag/#findComment-656832 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 />"; } Link to comment https://forums.phpfreaks.com/topic/126972-solved-get-value-inside-tag/#findComment-656836 Share on other sites More sharing options...
Brandon Jaeger Posted October 4, 2008 Author Share Posted October 4, 2008 Thanks! Link to comment https://forums.phpfreaks.com/topic/126972-solved-get-value-inside-tag/#findComment-656842 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]; } Link to comment https://forums.phpfreaks.com/topic/126972-solved-get-value-inside-tag/#findComment-657850 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.