xiao Posted April 23, 2008 Share Posted April 23, 2008 I create my array like this: $_SESSION['ECpc'] = $productcodeEC; $_SESSION['ECid'] = $rij['products_id']; $_SESSION['ECprijs'] = $rij['products_price']; $_SESSION['ECnaam'] = $rij['products_name']; And add stuff to it like this: array_push($_SESSION['ECpc'], $productcodeEC); array_push($_SESSION['ECid'], $rij['products_id']); array_push($_SESSION['ECprijs'], $rij['products_price']); array_push($_SESSION['ECnaam'], $rij['products_name']); And I delete from it like this: array_splice($_SESSION['ECpc'],$id,1); array_splice($_SESSION['ECid'],$id,1); array_splice($_SESSION['ECprijs'],$id,1); array_splice($_SESSION['ECnaam'],$id,1); It all works fine, unless I delete $id = 0, then php always deletes $id = 0 and $id = 2... ??? Link to comment https://forums.phpfreaks.com/topic/102519-weird-problem-when-emptying-array/ Share on other sites More sharing options...
DarkWater Posted April 23, 2008 Share Posted April 23, 2008 Unless those are all multidimensional arrays, I don't know why you're using array_push and array_splice instead of just assigning new keys for each value. Link to comment https://forums.phpfreaks.com/topic/102519-weird-problem-when-emptying-array/#findComment-524884 Share on other sites More sharing options...
xiao Posted April 23, 2008 Author Share Posted April 23, 2008 they're 2-dimensional Link to comment https://forums.phpfreaks.com/topic/102519-weird-problem-when-emptying-array/#findComment-524885 Share on other sites More sharing options...
DarkWater Posted April 23, 2008 Share Posted April 23, 2008 Oh, okay, I just needed to make sure. So the problem is that PHP deletes 2 and 0 when $id = 0? Link to comment https://forums.phpfreaks.com/topic/102519-weird-problem-when-emptying-array/#findComment-524887 Share on other sites More sharing options...
xiao Posted April 23, 2008 Author Share Posted April 23, 2008 oh, sorry, typo. It deletes id = 1 and id = 0, not id = 2. Link to comment https://forums.phpfreaks.com/topic/102519-weird-problem-when-emptying-array/#findComment-524905 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.