blackoprogue Posted June 18, 2011 Share Posted June 18, 2011 My code opens a text file that is updated every 15 minutes and formats the values accordingly. My problem is that they now want to have the information displayed in a different order than what is being pulled from the text file. I'm a novice at PHP still and haven't been able to come up with how to get this accomplished. They want to have the information displayed by Node in numerical order instead of however the information in brought in. $filename = 'TEST.TXT'; $fp = fopen($filename, "r"); $contents = fread($fp, filesize($filename)); fclose($fp); $count = 1; $tok = strtok($contents, " \n"); while($tok) { switch ($count) { case 1: $count++; break; case 2: if($tok == "AVAILABLE") { $tok = strtok(" \n"); $tok = strtok(" \n"); } if($tok >= $time) $time = $tok; $count++; break; case 3: if($tok == "MA06") $tok = " <string>Node10</string> \n"; if($tok == "HS02") $tok = " <string>Node13</string> \n"; if($tok == "MB08") $tok = " <string>Node14</string> \n"; if($tok == "RRG1") $tok = " <string>Node28</string> \n"; if($tok == "MVS1") $tok = " <string>Node42</string> \n"; if($tok == "HS01") $tok = " <string>Node46</string> \n"; if($tok == "MIX1") $tok = " <string>Node49</string> \n"; if($tok == "WIN0") $tok = " <string>Node1</string> \n"; if($tok == "XRC0") $tok = " <string>Node2</string> \n"; if($tok == "SYS6") $tok = " <string>Node3</string> \n"; if($tok == "DEV0") $tok = " <string>Node4</string> \n"; if($tok == "WIN5") $tok = " <string>Node5</string> \n"; if($tok == "CMC1") $tok = " <string>Node6</string> \n"; if($tok == "ARG1") $tok = " <string>Node8</string> \n"; if($tok == "OTI1") $tok = " <string>Node115</string> \n"; if($tok == "OTI3") $tok = " <string>Node139</string> \n"; $lpar .= $tok; $count++; break; case 4: if($tok == "999.9") $hint = "IPL being perfomed \non reporting lpar"; if($tok < "999.9") $hint = $tok; if($tok == "999.9") $color = "009DFF"; if($tok == "999.9") $tok = "100.4"; if($tok >= "0" && $tok < "85") $color = "00B300"; if($tok >= "85" && $tok < "90") $color = "FFCF21"; if($tok >= "90" && $tok < "95") $color = "FF8620"; if($tok >= "95" && $tok <= "100") $color = "FF0000"; $spoolper .= " <number bevel='data' tooltip='". $hint . "'>" . $tok . "</number> \n"; $colorpic .= " <color>" . $color . "</color> \n"; $count = 1; break; default: break; } // end switch $tok = strtok(" \n"); } // end while $spool .= "\n" . $lpar . " </row> \n <row> \n <string>region A</string> \n" . $spoolper; $spool .= $filler1 . "<text transition='none' shadow='low' color='000000' alpha='100' size='12' x='374' y='467' width='100' height='50' h_align='left' v_align='top'>" . $time . "</text> \n" . $filler2; $spool .= $colorpic . "\n </series_color> \n"; return $spool; Any help would be greatly appreciated. Thank you. Quote Link to comment https://forums.phpfreaks.com/topic/239708-help-sorting-array-built-from-external-file/ Share on other sites More sharing options...
pornophobic Posted June 18, 2011 Share Posted June 18, 2011 You have a few options. I won't do it for you, but I will point you in the right direction and if you have any questions I can help you solve those as you go through it. Sorting Arrays with PHP Quote Link to comment https://forums.phpfreaks.com/topic/239708-help-sorting-array-built-from-external-file/#findComment-1231380 Share on other sites More sharing options...
blackoprogue Posted June 29, 2011 Author Share Posted June 29, 2011 Sorry for the delay, got a bit busy. I'll start working with those sorts and see what I can get going. Thank you for your guidance. Quote Link to comment https://forums.phpfreaks.com/topic/239708-help-sorting-array-built-from-external-file/#findComment-1236179 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.