Jump to content

Cleanup


CONFUSIONUK

Recommended Posts

Wondering if anyone had any idea where I could tidy this script up or even if there's any obvious flaws  :shy:

 

<?php
$open = fsockopen("00.00.00.00", "0000");
if ($open) {
fputs($open, "GET /7.html HTTP/1.1\nUser-Agent:Mozilla\n\n");
$read	= fread($open, 1000);
$one	= explode(",", $read);	$one	= $one[1];		$one	= str_replace("</body></html>", "", $one);
$two	= explode(",", $read);	$two	= $two[2];		$two	= str_replace("</body></html>", "", $two);
$three	= explode(",", $read);	$three	= $three[3];		$three	= str_replace("</body></html>", "", $three);
$four	= explode(",", $read);	$four	= $four[4];		$four	= str_replace("</body></html>", "", $four);
$five	= explode(",", $read);	$five	= $five[5];		$five	= str_replace("</body></html>", "", $five);
$six	= explode(",", $read);	$six	= $six[6];		$six	= str_replace("</body></html>", "", $six);
}
?>

Link to comment
https://forums.phpfreaks.com/topic/267876-cleanup/
Share on other sites

<?php
$open = fsockopen("00.00.00.00", "0000");
$dataArray = array();
if ($open) {
fputs($open, "GET /7.html HTTP/1.1\nUser-Agent:Mozilla\n\n");
$read	= fread($open, 1000);
$data = explode(",", $read);

foreach ($data as $item) {
	$dataArray[] = str_replace("</body></html>", "", $item);
}	

var_dump($dataArray);
}

 

Should make it cleaner, and less redundant. Hopefully it is self explanatory.

Link to comment
https://forums.phpfreaks.com/topic/267876-cleanup/#findComment-1374412
Share on other sites

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.