Schlo_50 Posted February 25, 2008 Share Posted February 25, 2008 Hey guys, I have some code which gathers information submitted from a form by users. The information is stored in an array separated by commas. I need to print out the data ($orderid and $quantity) stored in the array, but it needs to be exploded and displayed in two rows. At the moment when i print out the data a string separated by commas is displayed. Any help? if (isset($_POST['update']) && ($_POST['update']==="Review Order")) { $orderid = array(); $quantity = array(); $price = array(); foreach($_POST['orderid'] as $id){ $orderid[] = $id; $quantity[] = $_POST['quantity'][$id]; $price[] = $_POST['price'][$id]; $subtotals[] = $_POST['price'][$id] * $_POST['quantity'][$id]; $total += $_POST['price'][$id] * $_POST['quantity'][$id]; } $orderid = implode(',', $orderid); $quantity = implode(',', $quantity); $price = implode(',', $price); $_SESSION['Total'] = $total; $_SESSION['orderID'] = $orderid; $_SESSION['Quantity'] = $quantity; print "<br /><br /><table width=\"300\" border=\"1\" cellspacing=\"0\" cellpadding=\"0\" class=\"main2\"> <tr> <td><strong>Order Id</strong></td> <td><strong>Quantity</strong></td> <td><strong>Individual Price (£)</strong></td> </tr> <tr> <td>$orderid</td> <td>$quantity</td> <td>$price</td> </tr> </table><br /><br />"; print "<span class=\"main2\">Total: £$total</span>"; Thanks for any help guys! Link to comment https://forums.phpfreaks.com/topic/92888-exploding-arrays/ Share on other sites More sharing options...
Schlo_50 Posted February 25, 2008 Author Share Posted February 25, 2008 bump Link to comment https://forums.phpfreaks.com/topic/92888-exploding-arrays/#findComment-475924 Share on other sites More sharing options...
uniflare Posted February 25, 2008 Share Posted February 25, 2008 not exactly sure what your trying to do (im dumb ) but have you tried explode(",",$array); ? Link to comment https://forums.phpfreaks.com/topic/92888-exploding-arrays/#findComment-475996 Share on other sites More sharing options...
Orio Posted February 25, 2008 Share Posted February 25, 2008 First of all, if you want it to be in an regular array, and not in a comma separated string, don't implode the arrays. I don't really understand what exactly you want to print in each row. Orio. Link to comment https://forums.phpfreaks.com/topic/92888-exploding-arrays/#findComment-475998 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.