[thelist] split() etc

Roger Harness magic32 at jps.net
Wed Oct 8 15:48:56 CDT 2003


'Volters,

i can populate an html table by using a couple of split() functions so that
if the user types his info separated by commas, and then hits a carraige
return. the commas separate the cells, while the carraige returns separate
the table rows.

<form>
<textarea name='items'></textarea>
<br /><br />
<input type='submit'>
</form>

<table border=1>
<tr>
<?php
make_table($items);

function make_table($txt)
{
$textone=split("\r",$txt);
print "<table border=1>";
        foreach ($textone as $temp)
        {
        $texttwo=split(",",$temp);
        print "<tr>";
                foreach ($texttwo as $temp2)
                {
                print "<td>$temp2</td>";
                }
        print "</tr>";
        }
print "</table>";
}
?>

AND, i can let the user enter different rows on different text areas:

<html>
<body>
<form method='get' action='form_maker3da.php'>enter row data<br>
<textarea name='items[]'></textarea>
<br><br>
<form>enter row data<br>
<textarea name='items[]'></textarea>
<br /><br />
<input type='submit'>
</form>
</body>
</html>

which goes to:

<html>
<body>
<?php
print "<table border=1>";
foreach($items as $temp)
{
        print "<tr>";
        print "<td>$temp</td>";
        print "</tr>";
}
print "</table>";
?>
</body>
</html>

but what I'd *like* to do, is combine these two solutions.

so on the first text area, the user could input dogs, cats, birds
and on the next text area they could enter horses, worms, fish

so i'm getting each row from a different text area, but its still splitting
on the commas, instead of the carraige return.

and of course populate a single table with all this exciting information.

am i even making sense on here?

as always, tia!

-Roger Harness



More information about the thelist mailing list