Bug #1629: for x undefined values in an array, implode concatenates the last x + 1 items

From: Date: Tue, 29 Jun 1999 22:20:57 +0000
Subject: Bug #1629: for x undefined values in an array, implode concatenates the last x + 1 items
Groups: php.dev 
Request: Send a blank email to php-dev+get-7842@lists.php.net to get a copy of this message
From: codemaster@randombytes.com Operating system: Linux x86 PHP version: 3.0.7 PHP Bug Type: Misbehaving function Bug description: for x undefined values in an array, implode concatenates the last x + 1 items <table border=3> <tr><th colspan=6>Original array = ("abc", "def", "ghi", "jkl", "stuck", "together")</th></tr> <tr bgcolor=ff0000> <th>0 = undef <th>1 = undef <th>2 = undef <th>3 = undef <th>4 = undef <th>5 = undef </tr> <tr bgcolor=ffff88> <!-- *** PART 1 *** --> <?php $x = array("abc", "def", "ghi", "jkl", "stuck", "together"); for ($i = 0; $i < count($x); $i++) { echo "<td valign=top>"; $temp = $x[$i]; $x[$i] = $y; echo implode("<br>", $x); $x[$i] = $temp; echo "</td>"; } ?> </tr> <tr><th colspan=6>Original array = array($y)</th></tr> <tr bgcolor=ff0000> <th>1 items <th>2 items <th>3 items <th>4 items <th>5 items <th>6 items </tr> <tr bgcolor=ffff88> <!-- *** PART 2 *** --> <?php $x = array($y); for ($i = 1; $i < 7; $i++) { echo "<td valign=top>"; $x[$i] = "item$i"; echo implode("<br>", $x); echo "</td>"; } ?> </tr> <tr><th colspan=6>Original array = array("abc", "def", "ghi", "jkl", "mno", "pqr", "stu", "vwx", "123", "456", "789")</th></tr> <tr bgcolor=ff0000> <th>1 undef <th>2 undefs <th>3 undefs <th>4 undefs <th>5 undefs <th>6 undefs </tr> <tr bgcolor=ffff88> <!-- *** PART 3 *** --> <?php $x = array("abc", "def", "ghi", "jkl", "mno", "pqr", "stu", "vwx", "123", "456", "789"); for ($i = 0; $i < count($x); $i++) { echo "<td valign=top>"; $x[$i] = $y; echo implode("<br>", $x); echo "</td>"; } ?> </tr> </table>

« previous php.dev (#7842) next »