Jump to content

Selecting a column of a Table?


Cragsterboy

Recommended Posts

ok im making a report converter for a game, it converts a report into bbcode to be pasted into the forums, but when i do it atm it all collects on the left side of the forum. SO my converter atm outputs the bb code into a table and i was wanting the right column of the tables cells to have [ center] tags around them so when the bbcode is copied and pasted into the forums it looks more formatted:)

 

Here is the current code to my table:

 


$bbword = explode("\n", trim($bbword));

echo '<table><td>'; // Start a table

$size = count($bbword);
$valBreak = '</td><td>'; // Set the value that will be put between the values
for($i = 0; $i < $size; ++$i) {
echo $bbword[$i];

// See if the next value starts with '-' and output it if it is
if(isset($bbword[$i+1]) && $bbword[$i+1][0] == '-') {
	echo ' ' . $bbword[$i+1];
	++$i; // Move the pointer up one since we've outputted 2 values this loop
}

// Output the between-item value if it isn't the last loop of the array
if(isset($bbword[$i+1])) {
	echo $valBreak;
}

// Swap the between-item value every other loop
$valBreak = ($valBreak == '</td><td>') ? '</td></tr><tr><td>' : '</td><td>';
}

echo '</td></tr></table>'; // End the table

 

so how would i be able to do it?

 

Thanks

 

~Crag

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.