php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #76434 implode sometimes ignores one array item
Submitted: 2018-06-08 23:12 UTC Modified: 2018-06-10 13:48 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:0 of 1 (0.0%)
From: ceeckels at mac dot com Assigned:
Status: Not a bug Package: Arrays related
PHP Version: 7.1.18 OS: MacOS, FreeBSD
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: ceeckels at mac dot com
New email:
PHP Version: OS:

 

 [2018-06-08 23:12 UTC] 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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-06-08 23:35 UTC] danack@php.net
-Status: Open +Status: Feedback
 [2018-06-08 23:35 UTC] 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:53 UTC] danack@php.net
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;
 [2018-06-10 10:52 UTC] ceeckels at mac dot com
-Status: Feedback +Status: Closed
 [2018-06-10 10:52 UTC] ceeckels at mac dot com
The problem is not PHP-related. It is a problem wit Apple's Terminal.app. The string output by the bash command

echo -e '12345678\t12345678\t12345678\t3\t4\t5\t6\t7\t8'

depends on the Terminal windows's width.

So I owe an apology to PHP's implode function.

Thanks to everybody. Bug should be closed.
 [2018-06-10 13:48 UTC] requinix@php.net
-Status: Closed +Status: Not a bug
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 03 10:01:33 2025 UTC