rain13 Posted July 28, 2011 Share Posted July 28, 2011 I am trying to match {{filename.extension}} <?php$string = '{{file.html}} some random crap {{file2.html}}';$pattern = '/\{\{(\w+\.\w+)\}\}/s';preg_match_all($pattern, $string, $matches);foreach ($matches as $match) { echo $match[0]."\n";}?> but this code outputs me {{file.html}}file.htmlWhat and how I need to change if I want that output look like that?{{file.html}}{{file2.html}}Edit: found code from internet and built thisforeach ($matches[0] as $key => $match) { echo $matches[1][$key]."\n";} I can't understand what $key => $matchwhat does => do in there. Link to comment Share on other sites More sharing options...
jeffman Posted July 28, 2011 Share Posted July 28, 2011 1. Since your subject line now says [solved], don't be surprised that this post is no longer receiving replies. You have a new question on a new topic, so start a new thread.2. The online manual answers your question pretty clearly here.FYI, for all functions and many other topics, you can get quick access to information in the online manual like this: www.php.net/topic . In this case, I typed this in my browser's URL bar: www.php.net/foreach , and the PHP site redirected me to the correct page. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.