PHP implode limit bug?
Asked Answered
H

3

1

I've got a script that creates an array with around 40,000 entries, PHP arrays have no limit except the memory of the server...

However the PHP function implode() simply does not output anything, when trying to implode an array of around 40,000 entries into a string. Each array entry has about a sentence worth of a-Z characters. No memory errors, no errors at all!

Can anyone confirm this?

I'm not sure its possible to post examples!

EDIT (2013-06-03):

I can confirm that the PHP memory limit was set to -1 and PHP errors were to to E_ALL. There where no errors and simply no output. This seems to be an bug with PHP of some sort.

I was using echo implode("<br>\n", $myLogArr); with did not error or output anything, I've mananage to get the correct expected result by using foreach ($myLogArr as $line) echo $line."<br>\n";

Hilltop answered 31/5, 2013 at 14:50 Comment(4)
Did you check this? #13846427Inky
Don't you reach the memory_limit set in php.ini ?Pilsen
set_time_limit to check also.... put set_time_limit(0); at the beginning of your code then try to run it.Derwon
Check this fiddle it worksRandalrandall
R
1

The following works just fine - with 50,000 entries.

<?php
$arr = array();
for ($i = 0; $i < 50000; $i++) {
    $arr[] = str_shuffle('This sentance is of average length, which The Internet says is about 14.2 words.');
}
echo implode(PHP_EOL, $arr);

I would suggest increasing error_reporting and attempting to debug this further.

Anthony.

Rabbit answered 31/5, 2013 at 14:57 Comment(0)
Y
0

memory_limit to -1 and then execute your script in try catch block

Yahairayahata answered 31/5, 2013 at 14:56 Comment(0)
E
0
$string = str_repeat("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz,",1000000);
$array = explode(",", $string);
var_dump(sizeof($array), strlen(implode(",", $array)));

outputs:

int 1000001
int 53000000

OP, can you please show your code?

Emeryemesis answered 31/5, 2013 at 14:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.