Hey my name's izzy and i have been around the web designing game for a while and i was trying to figure out how we can get the explode function to support javascript in a web page when splitting ..
here's the code :

function snp($str_to_look_for, $str_to_stop_at, $html)
    //echo $str_to_look_for . "     " . $str_to_stop_at .  "    " . $html . "<br>\n";

    //Start Reading Our Piece That We Need.
    $output = explode($str_to_look_for, $html);
    $output = $output[1]; // Array index 1 is the part we need it to start reading after.

    //Stop Reading.
    $output = explode($str_to_stop_at, $output);
    $output = $output[0]; // Array index 0 is the part we need it to stop reading before which in this case is junk to us.

    ///// Replacements if needed to match fonts and colors etc. to your site.  syntx. 'Search_For', 'Replace_with', $String
    //$output = str_replace('<param name="movie" value="', '<param name="movie" value="http://www.flash-game.net/game/2910/', $output);
    //$output = str_replace('<embed src="', '<embed src="http://www.flash-game.net/game/2910/', $output);

    //echo $output;
    return $output; 

if (!isset($_GET['v']))
echo "No results";

$url_to_fetch = $_GET['v'];
$url_to_fetch = 'http://youtube.com/watch?v=' . $url_to_fetch;
//echo $url_to_fetch;

$html = implode('', file($url_to_fetch));

//Regular HTML, user single quotes, and for special characters, use double quotes(for ex. \n or \t etc.
$str_to_look_for = 'type="text" value=\'';

$str_to_stop_at = '\' onClick="javascript';

$player = snp($str_to_look_for, $str_to_stop_at, $html);
echo html_entity_decode($player);


What this does is .. it visits youtube for a videeo that has been sent from other file on my webpage .. say .. http://youtube.com/watch?v=rnzoI9Xg_cU for example ..

$html = implode('', file($url_to_fetch));  // this is the code that gets the code fron that url into an array..  

but if a javascript is involved in that page its unable to get the javascript code .. all the native html is supported but no javascript is .. is there another approach to do this ?
any help would be appreciated.

Recommended Answers

All 4 Replies

$html = implode('', file($url_to_fetch)); // this is the code that gets the code fron that url into an array..

It won't gets the code from the url into an array. Try


$html will have the contents(javascript,css,..) of www.daniweb.com as a string.

Or try to use regular expressions and regular expression functions in PHP.

if the website that im trying to retrieve has a web browser check code or version check, wouldn't it return an incompatible browser message though ?

Umm.. I am not aware of it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.