Bug #76434 [Com]: implode sometimes ignores one array item
| From: | danack@php.net | Date: | Fri, 08 Jun 2018 23:53:55 +0000 |
| Subject: | Bug #76434 [Com]: implode sometimes ignores one array item | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-215553@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=76434&edit=1
ID: 76434
Comment by: danack@php.net
Reported by: ceeckels at mac dot com
Summary: implode sometimes ignores one array item
Status: Feedback
Type: Bug
Package: Arrays related
Operating System: MacOS, FreeBSD
PHP Version: 7.1.18
Block user comment: N
Private report: N
New Comment:
Also, this has a very small chance of being a weird interaction between your terminal and the bytes.
Please could you run this to see what implode is actually doing.
function getRawCharacters($result) {
$resultInHex = unpack('H*', $result);
$resultInHex = $resultInHex[1];
$resultSeparated = implode(', ', str_split($resultInHex, 2));
return $resultSeparated;
}
$ar = [12345678, 12345678, 12345678, 3, 4, 5, 6, 7, 8];
$string = implode(chr(9), $ar);
echo getRawCharacters($string) . PHP_EOL;
Previous Comments:
------------------------------------------------------------------------
[2018-06-08 23:35:13] danack@php.net
I can't reproduce https://3v4l.org/kEBSX and it sounds
weird.
Please can you test again with opcache disabled, if it's currently enabled.
Also please try with all other extensions disabled.
------------------------------------------------------------------------
[2018-06-08 23:12:01] ceeckels at mac dot com
Description:
------------
No comment; just run the test script and notice that the array item 7 is missing in the result
string
Test script:
---------------
<?php
$ar = [12345678, 12345678, 12345678, 3, 4, 5, 6, 7, 8];
echo implode(chr(9), $ar), PHP_EOL;
?>
Expected result:
----------------
12345678 12345678 12345678 3 4 5 6 7 8
Actual result:
--------------
12345678 12345678 12345678 3 4 5 6 8
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=76434&edit=1