I’m using PHP Simple HTML DOM Parser to grab some values I need.
What I’m trying to do now, is to grab a part of an URL.
This is how the source looks:
<a class="base-header-soldier-link" href="/bf3/soldier/someprofile/stats/123456789/">
someprofile
</a>
I’m trying to retrieve the value “123456789”, without the rest of the URL.
I’m using this code to retrieve the URL:
foreach($html->find('.base-header-soldier-name a') as $e)
{
$battlelog_id = $e->href;
}
So basically I want to strip it for the rest of the URL.
The URL can change depending on username, so “someprofile” will be replaced.
Can any of you help me out?
You can do it in a couple of ways the easiest is basename()
Or a more robust way is pathinfo()
Or even explode()