3v4l.org

run code in 300+ PHP versions simultaneously
<?php $a=['ref'=>&$a]; $a['val']=$a; var_dump($a); //normal, as expected var_dump(unserialize(serialize($a))); //half-arsed
Output for 8.0.0 - 8.0.8
array(2) { ["ref"]=> *RECURSION* ["val"]=> array(1) { ["ref"]=> *RECURSION* } } array(2) { ["ref"]=> &array(2) { ["ref"]=> *RECURSION* ["val"]=> array(1) { ["ref"]=> *RECURSION* } } ["val"]=> array(1) { ["ref"]=> &array(2) { ["ref"]=> *RECURSION* ["val"]=> array(1) { ["ref"]=> *RECURSION* } } } }
Output for 7.3.0 - 7.3.29, 7.4.0 - 7.4.21
array(2) { ["ref"]=> &array(2) { ["ref"]=> *RECURSION* ["val"]=> array(1) { ["ref"]=> *RECURSION* } } ["val"]=> array(1) { ["ref"]=> &array(2) { ["ref"]=> *RECURSION* ["val"]=> *RECURSION* } } } array(2) { ["ref"]=> &array(2) { ["ref"]=> *RECURSION* ["val"]=> array(1) { ["ref"]=> *RECURSION* } } ["val"]=> array(1) { ["ref"]=> &array(2) { ["ref"]=> *RECURSION* ["val"]=> array(1) { ["ref"]=> *RECURSION* } } } }

preferences:
154.48 ms | 462 KiB | 5 Q