parsing through html with php
<p>while working on facebook connect I have to retrieve an access token from a url ( it is not in the url itself but in the file lined to that url) so this is what I do </p>

<pre><code>$url = "https://graph.facebook.com/oauth/access_token?client_id=".$facebook_app_id."&amp;redirect_uri=http://www.example.com/facebook/oauth/&amp;client_secret=".$facebook_secret."&amp;code=".$code;"

function get_string_between($string, $start, $end){ 
    $string = " ".$string; 
    $ini = strpos($string,$start); 
    if ($ini == 0) return ""; 
    $ini += strlen($start); 
    $len = strpos($string,$end,$ini) - $ini; 
    return substr($string,$ini,$len); 
} 


$access_token = get_string_between(file_get_contents($url), "access_token=", "&amp;expires=");  
</code></pre>

<p>it looks ugly and clumsy is there a better way to do it ? thank you .</p>
