makamo66 Posted October 28, 2019 Share Posted October 28, 2019 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. Quote Link to comment Share on other sites More sharing options...
ginerjm Posted October 29, 2019 Share Posted October 29, 2019 (edited) array_pop is just an array function that works on any array. Using it on a $_SESSION array is no different than any other array. If you pop something off an array it is no longer a member of that array and that's that. And using it on the $_SESSION array itself (and not a member array) is the same. Why do you think that using it on a $_SESSION array or $_SESSION itself would give you something different? PS - What is this "REQUEST" item that you mention? It is not an automatic entry that I know of. Edited October 29, 2019 by ginerjm Quote Link to comment Share on other sites More sharing options...
cyberRobot Posted October 29, 2019 Share Posted October 29, 2019 What are you looking to accomplish? Are you writing a script that processes all the information in the $_SESSION array and/or presumably the $_REQUEST array? If so, would using something like the foreach loop work for your project? That would allow you to process everything without destroying the original array. 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.