match user input url to url in php variable
<p>There is a variable</p>

<pre><code>$string = 'http://www.someurl.com/somerandom/page.php';
</code></pre>

<p>There is an input</p>

<pre><code>&lt;input type="text" class="theurl" /&gt;
</code></pre>

<p>I need to verify the first part of the data the user adds to the input matches the first part of the string. Meaning the user data should begin with:</p>

<pre><code>http://www.someurl.com/
</code></pre>

<p>But not verify whatever comes after that /, meaning the user can change the</p>

<pre><code>somerandom/page.php
</code></pre>

<p>part of things. I am very much still learning php and have come a long way, but this is WAY over my head.</p>

<p>Note I do not want to prefill the data for the user and do not know the variable link ahead of time. I just want to match and verify. Perhaps a mix of jquery/js and php?</p>

<p>I don't even know where to begin. Help? Perhaps example code specific to my issue? </p>

<p><strong>Update / Final</strong></p>

<p>So far here is what i have figured out</p>

<pre><code>$re = "/http:\\/\\/([^\\/\\r\\n]+)/"; 
$string = $baffiliate; 
$newstring = preg_match($re, $string, $matches);
foreach($matches as $key=&gt;$value)
    {
    $value = $value;
    }
if(strpos($_POST['affiliate'], $value) === false) {
echo 'error';
}else{
...do something
}
</code></pre>

<p>I opted to use this solution as it didn't require an extra count of thee variable during test :) </p>