Jump to content
php.lv forumi

array pievienot jaunus datus aiz vecajiem


anonīms

Recommended Posts

                            $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.

Link to comment
Share on other sites

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 by Grey_Wolf
Link to comment
Share on other sites

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'
);                           

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...