Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

abdulhalimmanik's avatar

Replace whole array inside a session.

I have session called cart like bellow

array:2 [▼
  0 => array:5 [▼
    "productId" => "1"
    "productTypeId" => "5"
    "productTypeName" => "Printed Wristbands"
    "productTypeSizeName" => "1/2 Inch"
    "productName" => "1/2 Inch Printed Wristbands"    
  ]
  1 => array:5 [▼
    "productId" => "2"
    "productTypeId" => "7"
    "productTypeName" => "Dual Layer Wristbands"
    "productTypeSizeName" => "1/2 Inch"
    "productName" => "1/2 Inch Dual Layer Wristbands"    
  ]
]

Now i want to replace index 1 with new array like

array:5 [▼
    "productId" => "3"
    "productTypeId" => "8"
    "productTypeName" => "Embossed Wristbands"
    "productTypeSizeName" => "1/2 Inch"
    "productName" => "1/2 Inch Embossed Wristbands"    
  ]

how can i do that?

0 likes
1 reply

Please or to participate in this conversation.