The commented out part is what I'm trying to match, I'm not sure whether to use: preg_match_all or preg_match //<form action="/forums/mostplays/test/" onsubmit="return validateSubmit()" method="POST" id="comment" name="comment"> preg_match_all('~<form action="/forums/(.*)"~i', $siteUrl, $matches); foreach ($matches[1] AS $match) { ?> Match: <?=$match?><br /><br /> <? } PHP: Thanks for the help
Hi, Not sure what you want to do. Do you want to get <form action="/forums/mostplays/test/" onsubmit="return validateSubmit()" method="POST" id="comment" name="comment"> from the $siteUrl variable that can contain anything? preg_match('~(<form action="/forums/.*?>)~i', $siteUrl, $matches); or do you want to get the 'mostplays/test/' part of the commented line? preg_match('~<form action="/forums/(.*?)"~i', $siteUrl, $matches);
Yes i'm trying to do the second part of what you wrote, I know how the following but am still not having any luck preg_match('~<form action="/forums/(.*?)"~i', $siteUrl, $matches); ?> Match: <?=$matches[1]?><br /><br /> PHP:
This is the code I've tested: $siteUrl = 'fdfs<form action="/forums/mostplays/test/" onsubmit="return validateSubmit()" method="POST" id="comment" name="comment">dfdf'; preg_match('~<form action="/forums/(.*?)"~i', $siteUrl, $matches); print_r($matches[1]); PHP: And it returns me mostplays/test/