0

i have an array $cart like

    array:5 [▼
  188 => array:17 [▼
    "user_id" => "176"
    "product_id" => "188"
    "qty" => "2"
    "date" => "03-05-2020"
    "product_type" => "rear type"
    "custom_color_title" => ""
    "custom_color_price" => ""
    "bolt_title" => ""
    "bolt_price" => ""
    "hub_center_rings_title" => ""
    "hub_center_rings_price" => ""
    "wheel_spacers_title" => ""
    "wheel_spacers_price" => ""
    "tire_pressure_title" => ""
    "tire_pressure_price" => ""
    "product_price" => 1890
    "product_size" => ""
  ]
  176 => array:17 [▼
    "user_id" => ""
    "product_id" => "176"
    "qty" => "2"
    "date" => "03-05-2020"
    "product_type" => "wheel type"
    "custom_color_title" => ""
    "custom_color_price" => ""
    "bolt_title" => ""
    "bolt_price" => ""
    "hub_center_rings_title" => ""
    "hub_center_rings_price" => ""
    "wheel_spacers_title" => ""
    "wheel_spacers_price" => ""
    "tire_pressure_title" => ""
    "tire_pressure_price" => ""
    "product_price" => 1680
    "product_size" => ""
  ]
  224 => array:17 [▶]
] 

how to update 188 position of qty value and delete 176 position ? $cart is session value stored variable and i have $qty = $_POST['qty']; $cartid = $_POST['cartid']; $qty is update value and $cartid is postion value .

1
  • 1
    $cart[188]['qty'] = {value} ? Commented May 4, 2020 at 7:52

1 Answer 1

1

for update you can use this

$array[188] = [
    'item_name' => 'value',
     ...
];

for delete you can use this

unset($array[176]);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.