I'v got a single string with text that I want to neatly output into a table.
I'v used explode to split up new lines. However I want to split it up further.
Like so
< table >
< tr > < td > Ken < / td > < td > : < / td > < td > My name is Ken, what is yours < / td > < / tr >
< tr > < td > Maria < / td > < td > : < / td > < td > My name is Maria. Where are you from ? < / td > < / tr >
.....
< / table >
I'v also tried using str_split and creating an additional for loop without any luck
How do I split up between names, : and the dialog ?
Below is what I managed to do so far :
<?php
$string = "
Ken : My name is Ken, what is yours ?
Maria : My name is Maria. Where are you from ?
Ken : I'm from Germany, and you ?
Maria : I'm from Spain.
Ken : Nice to meet you.
";
$explode_string = explode("\n",$string);
print "<table border=1>";
foreach($explode_string as $text_line) {
print "<tr><td>" . $text_line . "</td></tr>";
}
print "</table>";
?>