954,167 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

php explode function

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 . "
\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('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.

isomillennium
Light Poster
25 posts since Feb 2008
Reputation Points: 10
Solved Threads: 1
 
$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=htmlentities(implode("",file("http://www.daniweb.com")));

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

nav33n
Purple hazed!
Moderator
4,465 posts since Nov 2007
Reputation Points: 524
Solved Threads: 356
 

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

ryan_vietnow
Posting Pro
578 posts since Aug 2007
Reputation Points: 28
Solved Threads: 71
 

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 ?

isomillennium
Light Poster
25 posts since Feb 2008
Reputation Points: 10
Solved Threads: 1
 

Umm.. I am not aware of it.

nav33n
Purple hazed!
Moderator
4,465 posts since Nov 2007
Reputation Points: 524
Solved Threads: 356
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You