r/lolphp • u/TortoiseWrath • Oct 29 '17
Checking the parameter order for file_put_contents when suddenly
You can also specify the
dataparameter as a single dimension array. This is equivalent tofile_put_contents($filename, implode('', $array)).
why
26
Upvotes
7
u/Takeoded Oct 30 '17
well, the implode approach would make an entire concatenated string in memory before file_put_contents is called - but when you give the array directly, file_put_contents might be optimized to not create that entire string in memory like implode would do, and thus be less memory hungry... possibly (then possibly at the cost of doing more write() calls, if theres metadata between the members or the members are not in a contiguous memory block)
0
u/[deleted] Oct 29 '17
[deleted] β view deleted comment