Bug #18307 Updated: Using next () && prev() on session array
| From: | sniper@php.net | Date: | Sat, 13 Jul 2002 01:41:12 +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-14041@lists.php.net to get a copy of this message | ||
ID: 18307
Updated by: sniper@php.net
Reported By: submiturl@vaner.com
-Status: Open
+Status: Feedback
Bug Type: Arrays related
Operating System: WinXP
PHP Version: 4.2.1
New Comment:
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..
Previous Comments:
------------------------------------------------------------------------
[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