$set = ''; if ($sortby == '') { $sortby = 'field3'; $set = 'y'; } if ($sortby == 'field3') { $set = 'y'; } if ($set == '') { echo 'The variable at the end of the web address did not match one required by the code. Please check the web address for errors.'; exit; } $number = 0; $fp = fopen('data.txt','r'); if (!$fp) {echo 'ERROR: Unable to open file.'; exit;}
while (!feof($fp)) { $line = fgets($fp,1024); //use 2048 if very long lines $row++; list ($field1, $field2, $field3, $field4) = split ('\|', $line); if ($sortby == 'field3') $sortkey = strtolower($field3); $col[$row] = array($sortkey, $field1, $field2, $field3, $field4); }