Variables on PHP explode set to 1 character? -


i trying post 3 variables via checkbox.

if user ticks checkbox each product, trying send 3 variables:

<input type="checkbox" name="product[]" value="'. $rowattr["reference"] .'-'. $rowattr["price"] .'-'. $rowprod["unity"] .'"> 

the variables set have printed them page user can see product selecting. however, when submit form, variables checkbox set 1 characters? going wrong?

$selected = explode('-', $product); $reference = $selected[0]; $price = $selected[1]; $unity = $selected[2];  echo '<table class="table table-striped">';     echo '<th>product reference</th><th>price</th><th>unit</th>';         if(isset($_post['product'])) {             foreach($_post['product'] $product) {                 print '<tr>';                     print '<td>'. $product['reference'] .'</td>';                     print '<td>'. $product['price'] .'</td>';                     print '<td>'. $product['unity'] .'</td>';                 print '</tr>';             }         } echo '</table>'; 

try run code below

   $product = $_post['product'];    echo "<pre>";    var_dump($product);    echo "</pre>"; 

i think array this

  array(3){    [0]=>array(3) {[0]=>"some value",[1]=>"some value",[2]=>"some value",}     [1]=>array(3) {[0]=>"some value",[1]=>"some value",[2]=>"some value",}     [2]=>array(3) {[0]=>"some value",[1]=>"some value",[2]=>"some value",}    } 

so foreah or call $product[0][1], $product[0][2], $product[0][3] instead.


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -