- memory_get_peak_usage: documentation ( source)
- array_keys: documentation ( source)
- array_fill: documentation ( source)
- printf: documentation ( source)
<?php
$arr = array_fill(0, 100000, true);
printf("%.2f mb\n", memory_get_peak_usage() / 1024 / 1024);
foreach ($arr as $value) {
break;
}
printf("%.2f mb\n", memory_get_peak_usage() / 1024 / 1024);
foreach (array_keys($arr) as $value) {
break;
}
printf("%.2f mb\n", memory_get_peak_usage() / 1024 / 1024);