#47363 [Com]: for($i=4;$i<((func_num_args() + sizeof($array)));$i++) does not work.

From: Date: Thu, 12 Feb 2009 14:33:50 +0000
Subject: #47363 [Com]: for($i=4;$i<((func_num_args() + sizeof($array)));$i++) does not work.
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-133765@lists.php.net to get a copy of this message
 ID:               47363
 Comment by:       smlerman at gmail dot com
 Reported By:      devilx at devilx dot net
 Status:           Open
 Bug Type:         Arrays related
 Operating System: Linux, Mac OS X
 PHP Version:      5.2.9RC1
 New Comment:

Try checking the value of sizeof($wuergs) inside the loop. Hint: it
changes every time.


Previous Comments:
------------------------------------------------------------------------

[2009-02-12 04:15:07] devilx at devilx dot net

Description:
------------
The Calculation of sizeof + func_num_args within a for does not work /

ends in an endless-for.

Reproduce code:
---------------
f("this","is","a","test");

function f()
{
   $wuergs = array (
        0 => "1234",
        1 => "B",
        2 => "C",
        3 => "D"
    );

	$args=func_get_args();
	for($i=4;$i<((func_num_args() + sizeof($wuergs)));$i++)
	{
        	$wuergs[$i]=$args[$i-4];
    	}
	return l_backend($wuergs);
}

Expected result:
----------------
Moving the content of $args four arrays highr.

Actual result:
--------------
Endless loop.


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=47363&edit=1



Thread (3 messages)

« previous php.bugs (#133765) next »