anonīms Posted May 17, 2011 Report Share Posted May 17, 2011 $getDataCustom[$v1]['OrderItems'][1]['id'] = 9999; $getDataCustom[$v1]['OrderItems'][1]['order_id'] = $orderID; $getDataCustom[$v1]['OrderItems'][1]['product_id'] = 1791; //random product $getDataCustom[$v1]['OrderItems'][1]['vat'] = '0.00'; $getDataCustom[$v1]['OrderItems'][1]['amount'] = 1; $getDataCustom[$v1]['OrderItems'][1]['text'] = ''; if($orderDelivery==1) { $getDataCustom[$v1]['OrderItems'][1]['price'] = '3.90'; } else { $getDataCustom[$v1]['OrderItems'][1]['price'] = '0.00'; } /* example $getDataCustom[$v1]['OrderItems']['15'] ir ar pēdējo id items, vajag +1. Kā iegūt šo 15? */ ir neierobežots skaits orderitems['skaitlis']. Kā ir iespēja pēc pēdējā vnk pievienot jaunus datus? testa kodā, tas ir [1], bet, ja ir 2 ordera itemi, tad notiek pārslāņošanās. Quote Link to comment Share on other sites More sharing options...
xPtv45z Posted May 17, 2011 Report Share Posted May 17, 2011 count(getDataCustom[$v1]['OrderItems'])+1; Quote Link to comment Share on other sites More sharing options...
Grey_Wolf Posted May 17, 2011 Report Share Posted May 17, 2011 (edited) ir neierobežots skaits orderitems['skaitlis']. Kā ir iespēja pēc pēdējā vnk pievienot jaunus datus? testa kodā, tas ir [1], bet, ja ir 2 ordera itemi, tad notiek pārslāņošanās. Elementari Nenoradot neko .. $a[0]='xxx0'; ... $a[99]='xxx99'; $a[]='100'; echo $a[100]; // izvadiis 100 Edited May 17, 2011 by Grey_Wolf Quote Link to comment Share on other sites More sharing options...
indoom Posted May 17, 2011 Report Share Posted May 17, 2011 var arī tā $getDataCustom[$v1]['OrderItems'][] = array( 'id' => 9999, 'order_id' => $orderID, 'product_id' => 179, //random product 'vat' => '0.00', 'amount' => 1, 'text' => '', 'price' => $orderDelivery==1 ? '3.90' : '0.00' ); Quote Link to comment Share on other sites More sharing options...
mixis Posted May 17, 2011 Report Share Posted May 17, 2011 Varbūt der?: int array_push ( array &$array , mixed $var [, mixed $... ] ) Quote Link to comment Share on other sites More sharing options...
waplet Posted May 17, 2011 Report Share Posted May 17, 2011 Pilnībā piekrītu Pelēkā vilka variantam, manuprāt, sarežģīt dzīvi, savādāk risinot šo problēmu, nevajadzētu. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.