Warning: Division by zero in /var/customers/webs/stc/benchmark/index.php on line 256 Test: arrays vs. variables

PHP Benchmarks

Performance comparison of PHP code alternatives.

Test: arrays vs. variables

Not that using variables like this is good style, and array1 already mostly answers this.

Run Again Test Menu


Unfortunately, no history for this test is available.


The first test, "$array[$n]", was:

$array = array();
for ($i = 0; $i < 100; $i++)
	$array[$i] = $i;

The second test, "${'array_' . $n}", was:

for ($i = 0; $i < 100; $i++)
	${'array_' . $i} = $i;

Running: Linux (x86_64:1 GB) PHP (7.2.34-21+ubuntu16.04.1+deb.sury.org+1)