note 26311 deleted from function.sort by derick

From: Date: Wed, 31 Aug 2005 10:39:32 +0000
Subject: note 26311 deleted from function.sort by derick
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-94502@lists.php.net to get a copy of this message
Note Submitter: whit at transpect dot com ---- As I was prettying up the output I realized that removing that "-1" from the function creates an extra blank line in the array - but still is the only way I've found to get the final real line sorted. Here is the kludged version of my tabbed-ASCII table displayer that uses the function, which won't show the extra line if the value in the first column is empty. It also has an extra variable to set up top, $title. Other than that, it's to be pasted in place of the last half of the code in my post here just prior: $mem=file("$infile"); $line=explode("\t","$mem[0]"); $cnt=count($line); echo "<html><head><title>$title</title></head><body link=\"#ffff00\" alink=\#ff0000\" vlink=\"#00ffff\">"; echo "<table border=\"1\">"; echo "<tr><td colspan=\"$cnt\" bgcolor=\"#cc0000\"><font size=\"5\" color=\"#ffffff\">$title</font></td></tr><tr>"; for ($i=$firstcol;$i<$cnt;$i++) { echo "<td bgcolor=\"#000000\"><a href=\"$PHP_SELF?col=$i\">$line[$i]</a></td>"; } echo "</tr>"; $cnt=count($mem); for ($i=$firstcol;$i<$cnt;$i++) { $line=explode("\t","$mem[$i]"); $cnt2=count($line); for ($j=$firstcol;$j<$cnt2;$j++) { $mem2[$i][$j]=$line[$j]; } } if(!isset($col)) $col=$firstcol; $mem2=qsort_multiarray($mem2,$col); $x=1; for ($i=0;$i<$cnt;$i++) { for ($j=$firstcol;$j<$cnt2;$j++) { if ($mem2[$i][$firstcol]!="") { if ($j==$firstcol) { if ($x=="1") { echo "<tr>"; $x=0; } else { echo "<tr bgcolor=\"#dddddd\">"; $x=1; } } $show=$mem2[$i][$j]; if ($show=="") $show="&nbsp;"; echo "<td>$show</td>"; if ($j==($cnt2-1)) echo "</tr>"; } } } echo "</table></body></html>";

« previous php.notes (#94502) next »