I'm sure there's a way to do this, but I'm lost.
Let's say, for example, I wanted to separate this text into a table...
George Bob Joe
Joe George Bob
...so that each name goes into a separate <td> after it goes through a form submission. Of course, the data will be completely random so I can't use ereg_replace.
Any ideas?
Separating Raw Text into Tables
Moderator: General Moderators
-
Caped Knight
- Forum Commoner
- Posts: 33
- Joined: Wed Jan 01, 2003 6:20 pm
- Location: Somewhere...out there...
-
bionicdonkey
- Forum Contributor
- Posts: 132
- Joined: Fri Jan 31, 2003 2:28 am
- Location: Sydney, Australia
- Contact:
something like this
Code: Select all
<?
$text = "George Bob Joe Joe George Bob";
$array = explode(" ", $text);
?>
<table>
<tr> <?
for($i = 0; $i < count($array); $i++) {
echo "<td>". $array[$i] ."</td>";
} ?>
</tr>
</table>Or:
Code: Select all
<?php
$text = 'George Bob Joe Joe George Bob';
$array = explode(' ', $text);
echo '<table><tr>';
foreach($array as $value) {
echo '<td>' . $value . '</td>';
}
echo '</tr></table>';
?>