3v4l.org

run code in 300+ PHP versions simultaneously
<?php $a = 'time'; $b = 'more'; $array = compact( array( 'a', 'b' ) ); var_dump($array); var_dump($array['a']); echo PHP_EOL; $array = compact( 'a', 'b' ); var_dump($array); var_dump($array['a']);
Output for 7.4.0 - 7.4.33, 8.0.1 - 8.0.30, 8.1.0 - 8.1.29, 8.2.0 - 8.2.20, 8.3.0 - 8.3.8
array(2) { ["a"]=> string(4) "time" ["b"]=> string(4) "more" } string(4) "time" array(2) { ["a"]=> string(4) "time" ["b"]=> string(4) "more" } string(4) "time"

preferences:
151.58 ms | 403 KiB | 126 Q