Jump to content

[solved]Need regex help


Recommended Posts

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

What and how I need to change if I want that output look like that?
Edit: found code from internet and built this
foreach ($matches[0] as $key => $match) {	echo $matches[1][$key]."\n";}

I can't understand what $key => $matchwhat does => do in there.

Edited by SoItBegins
Link to comment
Share on other sites

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.

Edited by Deirdre's Dad
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...