[PHP-DEV] Bug #1629: for x undefined values in an array, implode concatenates the last x + 1 items From: codemaster <email protected>
Date: 06/29/99

From: codemaster <email protected>
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>

-- 
PHP Development Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-dev-unsubscribe <email protected>
For additional commands, e-mail: php-dev-help <email protected>
To contact the list administrators, e-mail: php-list-admin <email protected>