smart table construction from array

From: Date: Tue, 14 Aug 2001 16:02:16 +0000
Subject: smart table construction from array
Groups: php.general 
Request: Send a blank email to php-general+get-62667@lists.php.net to get a copy of this message
Hello All -- I have a csv file that I need to parse into a table. Getting the file open and into stuffed into an array is not really a problem, but I want PHP to adapt the table structure to the data on the fly. For example, some data (from the hgitner.com stamp buying list): 26,used,3¢ Washington Dull Red type II,$1.00 ,-,- "Fine + OG Hinged 232-40, 285-90, 294-99, 323-7 wanted. Call or ship!",,,,, 534A,single,"2¢ Washington, type VI (imperf, offset)",$20.00 ,$12.00 ,$6.00 534B,single,"2¢ Washington, type Va (imperf, offset)",Needed Urgently!,, I can easily get line 1 and 3 can easily into: <td>26</td><td>3¢ Washington Dull Red type II</td><td>$1.00</td><td>-</td><td>-</td> but line 2 and 4 are my problem. I want PHP to take line 2 and see that there is only one cell of data in the and four blanks in the array and thus create: <td colspan=5>Fine + OG Hinged 232-40, 285-90, 294-99, 323-7 wanted. Call or ship!</td> PHP should see that line 4 ends in two blanks and thus should output: <td>34B</td><td>single </td><td>2¢ Washington, type Va (imperf, offset) </td><td colspan=3>Needed Urgently!" but I'm having some real trouble figuring out the logic/control structures to do this. If there is a class out there that does this, I'd be happy to hear of it. But I suspect my inexperience is the real problem: I'm really hoping that someone can explain the logic of how this might be done. thanks in advance. peter -- Peter Torraca peter@torraca.net

« previous php.general (#62667) next »