Reputation: 3
Roan
I am currently looking into spliting a long row,from table1 and insert in multiple columns in another table2, the string the values are separated by a "/" and "-". is there a way to split a cell values at the occurrence of the "/" or "-" and insert in to the existing table2 in their separate columns?
I've a table with entries like this.
To turn this: table1
into this: table2
any help will be appreciated greatly
Upvotes: 0
Views: 208
Reputation: 1326
Try using
$data= "FO910/test123/KO9200-7890/asdasd23423"
$row = preg_split("/[\/\-]/", $data);
/* example output
array(1)
(
[0] => string(5) "FO910"
[1] => string(7) "test123"
[2] => string(6) "KO9200"
[3] => string(4) "7890"
[4] => string(12) "asdasd23423"
) */
foreach($col in $row )
{
echo '<td>'.$col.'</td>';
}
Upvotes: 1