This question already has an answer here:
I have an string in php like this pid1+2+price1+20+qty1+2+pid2+3+price2+20+qty2+1+
which is an outcome processing of some function. now I need to create table which should display the above result as
pid price qty 2 20 2 3 40 1
note: the result should be displayed as a string thanks
the function which i used to create the string is
$a=var_export($_REQUEST);
$b ='';
foreach($_REQUEST as $key=>$value)
{
$b.=$key."+".$value."+";
}
</div>
$array = array();
foreach ($_REQUEST as $key => $value) {
preg_match('/^([a-z]+)(\d+)$/', $key, $match);
$array[$match[2]][$match[$1] = $value;
}
echo "<table><tr><th>pid</th><th>price</th><th>qty</th></tr>";
foreach ($array as $row) {
echo "<tr><td>$row[pid]</td><td>$row[price]</td><td>$row[qty]</td></tr>";
}
echo "</table>";