|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2000-09-03 00:08 UTC] darron at froese dot org
This script works just fine in PHP 4.0.0 but fails in 4.0.1pl2, 4.0.2, PHP from CVS as of 8PM 09/02/2000. It's online and works here: PHP 4.0.0 <http://www.gary-campbell.com/test.php> Mandrake 7.0, Apache 1.3.12, Compiled as a DSO. It fails on this machine: PHP 4.0.2-cvs <http://www.educ8r.net/~darron/test.php> Mandrake 7.1, Apache 1.3.12, Compiled as a DSO. I tried it on a machine just now with the CVS version of PHP and it still fails. I've also tried it on a 4.0.2-release machine - it fails there too. <? for ($counter = 0; $counter < 11; $counter++) { $items[$counter] = $counter; } for ($counter = 0; $counter < 11; $counter++) { print "$counter = $items[$counter]<BR>\n"; } print "<P>"; for ($counter = 0; $counter < 11; $counter++) { print "$counter = $items[$counter]<BR>\n"; if (in_array("$counter", $items)) { $current_item = current($items); $previous_item = prev($items); print "Current: $current_item<BR>\n"; print "Previous: $previous_item<BR>\n"; } if (in_array("$counter", $items)) { $next_item = next($items); print "Next: $next_item<BR>\n"; } if ($prev_item) { print "Prev Item Exists<BR>\n"; } else { print "Prev Item Does NOT Exist<BR>\n"; } if ($next_item) { print "Next Item Exists<BR>\n"; } else { print "Next Item Does NOT Exist<P>\n"; } } ?> The php-4.0.0 was compiled with: ./configure \ --with-apxs=/usr/local/apache/bin/apxs \ --with-mysql=/usr/local/mysql-prod \ --with-pdflib \ --enable-ftp \ --with-ldap \ --with-imap=../imap-4.5 \ --with-zlib \ --with-jpeg-dir=/usr/lib \ --with-tiff-dir=/usr/lib \ --with-zlib-dir=/usr/lib \ --with-png-dir=/usr/lib \ --with-gd \ --with-ttf \ --with-xml \ --enable-trans-sid \ --enable-track-vars=yes \ --enable-magic-quotes=yes The php-4.0.2 was compiled with: ./configure \ --with-apxs=/usr/local/apache/bin/apxs \ --with-mysql=/usr/local/mysql-prod \ --with-pdflib \ --enable-ftp \ --with-ldap \ --with-imap=../imap-4.5 \ --with-zlib \ --with-jpeg-dir=/usr/lib \ --with-tiff-dir=/usr/lib \ --with-zlib-dir=/usr/lib \ --with-png-dir=/usr/lib \ --with-gd \ --with-ttf \ --with-xml \ --enable-trans-sid \ --enable-track-vars=yes \ --enable-magic-quotes=yes PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 11 16:00:02 2026 UTC |
> before using next, perv and current, you should do reset(). > Then, next and prev not only get items, but move array > pointer. Please read the manual about that. That's the behaviour you see in php 4.0.0 and the behaviour I'm used to (that's why there's two times I do "if (in_array("$counter", $items))"). It doesn't work in anything since then. This code works just fine in PHP 4.0.0 *with* or *without* the reset($items) - it's online and working at <http://gary-campbell.com/test.php> This code fails under any version of PHP since then on multiple machines. It's online and failing at <http://www.educ8r.net/~darron/test3.php> Here's the code: <? for ($counter = 1; $counter < 11; $counter++) { $items[$counter] = $counter; } for ($counter = 1; $counter < 11; $counter++) { print "$counter = $items[$counter]<BR>\n"; } print "<P>"; for ($counter = 1; $counter < 11; $counter++) { print "$counter = $items[$counter]<BR>\n"; reset($items); if (in_array("$counter", $items)) { $current_item = current($items); $previous_item = prev($items); print "Current: $current_item<BR>\n"; print "Previous: $previous_item<BR>\n"; } if (in_array("$counter", $items)) { $next_item = next($items); print "Next: $next_item<BR>\n"; } if ($previous_item) { print "Prev Item Exists<BR>\n"; } else { print "Prev Item Does NOT Exist<BR>\n"; } if ($next_item) { print "Next Item Exists<P>\n"; } else { print "Next Item Does NOT Exist<P>\n"; } } ?>