Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
display an array in 2 column ... need help
Old 11-21-2008, 07:12 PM display an array in 2 column ... need help
Experienced Talker

Posts: 38
Trades: 0
hi guys,

i have a list of files in a directory, but i need to display them in a table with 2 columns.

how can i do that with php?

eg,

table
col1 col2
file1 file2
file3 file4
file5 file6
file7

your help is much appreciated, thanks.

Last edited by superkingkong; 11-21-2008 at 07:15 PM..
superkingkong is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 11-21-2008, 11:51 PM Re: display an array in 2 column ... need help
NullPointer's Avatar
Will Code for Food

Posts: 2,784
Name: Matt
Location: Irvine, CA
Trades: 0
PHP Code:
$myArray = array( ... ); //your array of files

$table '<table>';
$switch true;
for(
int i 0count($myArray); i++)
{
     if(
$switch)
     {
          
$table .= '<tr><td>' $myArray[i] . '</td>';
     }
     else
     {
          
$table .= '<td>' $myArray[i] . '</td></tr>';
     }
     
     
$switch = !$switch;
}

if(!
$switch)
{
     
$table .= '</tr>';
}

$table .= '</table>'
That should work. There's a much cleaner way of doing it using sprintf but I'll leave that to you.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is offline
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 11-24-2008, 02:00 PM Re: display an array in 2 column ... need help
Experienced Talker

Posts: 38
Trades: 0
cool! it works.

thank you very much
superkingkong is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to display an array in 2 column ... need help
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.11370 seconds with 12 queries