4 Replies - 368 Views - Last Post: 29 October 2019 - 09:49 AM Rate Topic: -----

#1 makamo66   User is offline

  • D.I.C Head

Reputation: -5
  • View blog
  • Posts: 104
  • Joined: 04-February 09

Don't understand how array_pop is supposed to work on a SESSION ar

Posted 28 October 2019 - 04:42 PM

I want to use array_pop to remove the last item added to the SESSION array. So it would remove the REQUEST item. The problem is that nothing is left in the session array because I pop off the last item each time that the form is submitted. Maybe I need to use array_push to push the popped items back on to the SESSION array after the logic has been applied. I don't understand how array_pop is supposed to work on a SESSION array. Can anyone explain to me what behaviour to expect? I expected to get a SESSION array with the REQUEST item removed but I thought that I would still have all of my SESSION items.

Is This A Good Question/Topic? 0
  • +

Replies To: Don't understand how array_pop is supposed to work on a SESSION ar

#2 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 15427
  • View blog
  • Posts: 61,808
  • Joined: 12-June 08

Re: Don't understand how array_pop is supposed to work on a SESSION ar

Posted 28 October 2019 - 06:33 PM

Why would you be popping items off the session array?
Was This Post Helpful? 0
  • +
  • -

#3 makamo66   User is offline

  • D.I.C Head

Reputation: -5
  • View blog
  • Posts: 104
  • Joined: 04-February 09

Re: Don't understand how array_pop is supposed to work on a SESSION ar

Posted 29 October 2019 - 05:21 AM

I want to remove the newly submitted item, the REQUEST item from the SESSION array so that I can compare the SESSION array items with the REQUEST item and see if there are any duplicates. It's for a shopping cart application so if a duplicate product is found, the quantities for the two same products are added and only one product is shown. I have no idea how to do this and my code is a mess.
Was This Post Helpful? 0
  • +
  • -

#4 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 15427
  • View blog
  • Posts: 61,808
  • Joined: 12-June 08

Re: Don't understand how array_pop is supposed to work on a SESSION ar

Posted 29 October 2019 - 07:00 AM

Wouldn't you be wanting to add/remove things from an array object on the session array?

Ex:

https://www.plus2net...ray-session.php
Was This Post Helpful? 0
  • +
  • -

#5 ArtificialSoldier   User is online

  • D.I.C Lover
  • member icon

Reputation: 2458
  • View blog
  • Posts: 7,489
  • Joined: 15-January 14

Re: Don't understand how array_pop is supposed to work on a SESSION ar

Posted 29 October 2019 - 09:49 AM

Quote

I want to remove the newly submitted item, the REQUEST item from the SESSION array so that I can compare the SESSION array items with the REQUEST item and see if there are any duplicates.

That sounds like something you should do before adding things to the session array. Values don't get there automatically, you have to add everything, so it sounds like that's a step you should do when adding instead of after the fact.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1