CONFUSIONUK Posted September 1, 2012 Share Posted September 1, 2012 Wondering if anyone had any idea where I could tidy this script up or even if there's any obvious flaws <?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); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/267876-cleanup/ Share on other sites More sharing options...
premiso Posted September 1, 2012 Share Posted September 1, 2012 <?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. Quote Link to comment https://forums.phpfreaks.com/topic/267876-cleanup/#findComment-1374412 Share on other sites More sharing options...
CONFUSIONUK Posted September 1, 2012 Author Share Posted September 1, 2012 That seems to be a much better solution Quote Link to comment https://forums.phpfreaks.com/topic/267876-cleanup/#findComment-1374414 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.