Getting The ID Of URL
<p>Let say we have set of URLs like this</p>

<pre><code>yoursite.com/39827-key1-key2-key3
yoursite.com/132-key1-key2-key3
yoursite.com/9223455-key1-key2-key3
</code></pre>

<p>and so on
and let say with the help of .htaccess we can point all this urls to file say info.php
with the code </p>

<pre><code>&lt;?=id?&gt;
</code></pre>

<p>it should gives the following ids (with respect to each url)</p>

<pre><code>39827-key1-key2-key3
132-key1-key2-key3
9223455-key1-key2-key3
</code></pre>

<p>My question now is there any way that we only get the number before first (-)
let say</p>

<pre><code>$id = 39827-key1-key2-key3
</code></pre>

<p>we need to make it</p>

<pre><code>$realid = 39827
</code></pre>

<p>so i wonder if there any preg_replace or any any idea that can remove first (-) and all after it. </p>

<p>example</p>

<pre><code>For $id = 39827-key1-key2-key3
$realid = (something),$id
Then finally $realid = 39827
</code></pre>

<p>it will helps me to create easy understandable url and retrieve its data from database.</p>

<p>Thanks you and sorry for poor english.</p>
