Jump to content

Explode not working - need URL path


Johnny_NW

Recommended Posts

I am really confused here....

 

I'll insert URL for an embeded video, and it does embed the video onto the website.

 

And it also grabs the associated video thumbnail for that video from hosting server, IF and ONLY IF I put an absolute URL for the video thumbnail.

This isn't cool, because I don't want all my embed videos to have the same video thumbnail.

 

So the code works like this, but this gives the same video thumbnail for all videos:

$thumbnail = "http://cdn1.image.website.webcdn.com/201111/09/664006/original/8.jpg";

What I am tryign to do is get to /664006/ and insert my variable $url_id, which this works too, BUT still only the same video thumbnail /201111/09 :

$thumbnail = 'http://cdn1.image.website.webcdn.com/201111/09/' . $url_id . '/original/8.jpg';

So I know I need to get through /201111/09 to get to $url_id BUT THIS IS NOT WORKING :(

 

WHY is this not working? PLEASE any help would be sincerely appreciated:

$thumbnail = 'cdn1.image.website.webcdn.com/201111/09/664006/original/8.jpg';
$arr = explode('/', $thumbnail);
$url_id = $arr[3];
$thumbnail = 'cdn1.image.website.webcdn.com/'. $arr[1] . '/' . $arr[2] . '/' . $url_id . '/original/8.jpg';

Thanks for your help, in advance!

 

Link to comment
https://forums.phpfreaks.com/topic/280602-explode-not-working-need-url-path/
Share on other sites

Unfortunately, not working :confused:

 

I tried all of these:

$thumbnail = $_SERVER['DOCUMENT_ROOT'] . $arr[1] . '/' . $arr[2] . '/' . $url_id. '/original/8.jpg';
$thumbnail = $_SERVER['SERVER_NAME'] . $arr[1] . '/' . $arr[2] . '/' . $url_id. '/original/8.jpg';
$thumbnail = $_SERVER['HTTP_HOST'] . $arr[1] . '/' . $arr[2] . '/' . $url_id. '/original/8.jpg';

And I even tried:

$thumbnail = $_SERVER['DOCUMENT_ROOT'] . '/'. $arr[1] . '/' . $arr[2] . '/' . $url_id. '/original/8.jpg';

Any other suggestions? I am totally desperate for an answer, to be honest :

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.