Bug #18307 Updated: Using next () && prev() on session array

From: Date: Sun, 14 Jul 2002 03:39:59 +0000
Subject: Bug #18307 Updated: Using next () && prev() on session array
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-14115@lists.php.net to get a copy of this message
ID: 18307 Updated by: submiturl@vaner.com Reported By: submiturl@vaner.com -Status: Feedback +Status: Open Bug Type: Arrays related Operating System: WinXP PHP Version: 4.2.1 New Comment: from the manual : "The session support allows you to register arbitrary numbers of variables to be preserved across requests" Preserved means that the internal pointer of the array should be preserved to .. right??? i have posted this http://bugs.php.net/?id=18309 ( serialize of array doesn not preserve internal pointer) but its been calsified as bogus. Becasue Next() works on the array no defiend as a session array... it should work in the same manner on the session array. Previous Comments: ------------------------------------------------------------------------ [2002-07-12 21:41:12] sniper@php.net Why do you expect that to work? You don't store the current index anywhere, so it it's always starting from the first item.. ------------------------------------------------------------------------ [2002-07-12 21:22:22] submiturl@vaner.com The same thing happends on 4.2.1 version --- UPDATED CODE --- <? session_start(); if(!isset($_SESSION['array'])){ $_SESSION['array'] = Array(); $_SESSION['array'] []=count($_SESSION['array']); $_SESSION['array'] []=count($_SESSION['array']); $_SESSION['array'] []=count($_SESSION['array']); $_SESSION['array'] []=count($_SESSION['array']); $_SESSION['array'] []=count($_SESSION['array']); $_SESSION['array'] []=count($_SESSION['array']); $_SESSION['array'] []=count($_SESSION['array']); $_SESSION['array'] []=count($_SESSION['array']); $_SESSION['array'] []=count($_SESSION['array']); $_SESSION['array'] []=count($_SESSION['array']); print_r($_SESSION['array']); } if(isset($_REQUEST['programAction']) && $_REQUEST['programAction'] == "Next"){ next($_SESSION['array']); } if(isset($_REQUEST['programAction']) && $_REQUEST['programAction'] == "Prev"){ prev($_SESSION['array']); } echo current($_SESSION['array']); ?> <form name="form1" method="get" action="<?=$_SERVER['PHP_SELF']?>"> <input name="programAction" type="submit" id="programAction" value="Prev"> <input name="programAction" type="submit" id="programAction" value="Next"> </form> ------------------------------------------------------------------------ [2002-07-12 08:10:39] derick@php.net Thank you for taking the time to report a problem with PHP. Unfortunately you are not using a current version of PHP -- the problem might already be fixed. Please download a new PHP version from http://www.php.net/downloads.php If you are able to reproduce the bug with one of the latest versions of PHP, please change the PHP version on this bug report to the version you tested and change the status back to "Open". Again, thank you for your continued support of PHP. ------------------------------------------------------------------------ [2002-07-12 08:08:44] submiturl@vaner.com i was using PHP 4.1.2 ------------------------------------------------------------------------ [2002-07-12 07:57:02] submiturl@vaner.com I've tried to use next() and prev() on a array that was registerd with session. unfortunatelly it did not produce desired outcome. instead of traversing array fully it doesnt proceed after a second element. and when prev() is used the internal pointer gets stuffed so seach returns false. ----------------CODE--------- <? session_start(); if(!session_is_registered('session_array')){ session_register('session_array'); $session_array = Array(); $session_array []=count($session_array); $session_array []=count($session_array); $session_array []=count($session_array); $session_array []=count($session_array); $session_array []=count($session_array); $session_array []=count($session_array); $session_array []=count($session_array); $session_array []=count($session_array); $session_array []=count($session_array); $session_array []=count($session_array); print_r($session_array); } if(isset($programAction) && $programAction == "Next"){ next($session_array); } if(isset($programAction) && $programAction == "Prev"){ prev($session_array); } echo current($session_array); ?> <form name="form1" method="get" action="<?=$_SERVER['PHP_SELF']?>"> <input name="programAction" type="submit" id="programAction" value="Prev"> <input name="programAction" type="submit" id="programAction" value="Next"> </form> ----------------------------- ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=18307&edit=1

« previous php.bugs (#14115) next »