php - Create an array and calc
i'm from France i hope you'll understand me, i spent one year in usa, anyway...
Ok, i have a form, i received that from this form :
cmdId[] 25
cmdId[] 26
cmdId[] 27
cmdId[] 28
cmdId[] 29
cmdId[] 30
cmdId[] 31
cmdId[] 32
cmdId[] 33
cmdPrice[] 3.05
cmdPrice[] 3.46
cmdPrice[] 3.46
cmdPrice[] 550
cmdPrice[] 3.46
cmdPrice[] 4.3
cmdPrice[] 3.75
cmdPrice[] 3.3
cmdPrice[] 4.15
cmdQty[] 1
cmdQty[] 1
cmdQty[] 26
cmdQty[] 19
cmdQty[] 8
cmdQty[] 5
cmdQty[] 7
cmdQty[] 3
My form (just the important part)
echo '<tr>';
echo '<input type="hidden" value="'.$data3['LGCM_ID'].'" name="cmdId[]">';
echo '<td><input value="'.$data3['LGCM_QTE_COMMANDE'].'" name="cmdQty[]" id="cmdQty" type="text"></td>';
echo '<td>'.$data3['PRD_POIDS'].'</td>';
echo '<td>...</td>';
echo '<td>'.$data3['PRD_NAME'].'</td>';
echo '<td>'.$data3['PRD_LIBELLE'].'</td>';
echo '<td>data 2</td>';
echo '<td><input value="'.$data3['LGCM_PRIX_UNITAIRE'].'" name="cmdPrice[]" id="cmdPrice" type="text"> € HT</td>';
echo '<td>'.$data3['LGCM_PRIX_UNITAIRE'].' € TTC</td>';
echo '</tr>';
I want to create a array, then a foreach and getting the total like this :
Array 1
cmdId : 25
cmdQty: 20
cmdPrice : 10
=> subtotal : cmdQty * cmdPrice = 200
Array 2
cmdId : 26
cmdQty: 40
cmdPrice : 100
=> subtotal : cmdQty * cmdPrice = 4000
Total (subtotal + subtotal etc...)
I don't arrive to create a good foreach and a correct array in my case.
thanks
Answer
Solution:
assuming that all arrays are the same size and posted in same order:
Answer
Solution:
i made a mistake, if i wrote my json answer without print_r, i got the same message, look,
line 13 :
Allowed memory size of 134217728 bytes exhausted (tried to allocate 79 bytes) in /home/public_html/admin/cmd_execute_step2.php on line 13
Thanks.