942,516 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 5247
  • PHP RSS
Feb 15th, 2008
0

php explode function

Expand Post »
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);
//print_r($output);
$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);
//print_r($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";
exit;
}


$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.
Similar Threads
Reputation Points: 10
Solved Threads: 1
Light Poster
isomillennium is offline Offline
25 posts
since Feb 2008
Feb 15th, 2008
0

Re: php explode function

Quote ...
$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
php Syntax (Toggle Plain Text)
  1. $html=htmlentities(implode("",file("http://www.daniweb.com")));
$html will have the contents(javascript,css,..) of www.daniweb.com as a string.
Moderator
Featured Poster
Reputation Points: 524
Solved Threads: 356
Purple hazed!
nav33n is offline Offline
3,878 posts
since Nov 2007
Feb 15th, 2008
0

Re: php explode function

Or try to use regular expressions and regular expression functions in PHP.
Reputation Points: 28
Solved Threads: 71
Posting Pro
ryan_vietnow is offline Offline
578 posts
since Aug 2007
Feb 15th, 2008
0

Re: php explode function

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 ?
Reputation Points: 10
Solved Threads: 1
Light Poster
isomillennium is offline Offline
25 posts
since Feb 2008
Feb 15th, 2008
0

Re: php explode function

Umm.. I am not aware of it.
Moderator
Featured Poster
Reputation Points: 524
Solved Threads: 356
Purple hazed!
nav33n is offline Offline
3,878 posts
since Nov 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: help in mysql
Next Thread in PHP Forum Timeline: where can I get the source code of search, find, and view using php





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC