3v4l.org

run code in 500+ PHP versions simultaneously
<?php $data = str_repeat('abcde', 500000); $insertion = 'abc'; $position = 0; $data = substr($data, 0, $position) . $insertion . substr($data, $position); echo memory_get_peak_usage(), "\n";
Output for 5.6.0 - 5.6.40
7718360
Output for 7.0.0 - 7.0.33
7854368
Output for 7.1.0 - 7.1.33
7854384
Output for 7.2.0 - 7.2.34
5388376
Output for 7.3.0 - 7.3.33
5392320
Output for 7.4.0 - 7.4.33
5392400
Output for 8.0.0 - 8.0.30
5392096
Output for 8.1.0 - 8.1.34
5392624
Output for 8.2.0 - 8.2.34, 8.3.0 - 8.3.35
5392312
Output for 8.4.1 - 8.4.26
5392064
Output for 8.5.0 - 8.5.11
5466080

preferences:
48.47 ms | 1170 KiB | 27 Q