3v4l.org

run code in 300+ PHP versions simultaneously
<?php $test = array('customer-test1' => 1, 'customer-test2' => 2); function getPost($param) { global $test; echo addslashes($param)." = ".$test[$param]."<br/>"; return isset($test[$param]) ? $test[$param] : NULL; } class Customer { private $test1; private $test2; function __construct() { } } $object = new Customer(); $arr = (array)$object; $newArr = array(); foreach($arr as $key => $val) { $newKey = str_replace(get_class($object), "", $key); $newArr[$newKey] = getPost(strtolower(get_class($object))."-".$newKey); }
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Warning: Undefined array key "customer-" in /in/vgfI1 on line 5 customer-\0\0test1 = <br/> Warning: Undefined array key "customer-" in /in/vgfI1 on line 5 customer-\0\0test2 = <br/>
Output for 5.5.0 - 5.5.38, 5.6.0 - 5.6.30, 7.0.0 - 7.0.31, 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.31, 7.4.0 - 7.4.33
Notice: Undefined index: customer- in /in/vgfI1 on line 5 customer-\0\0test1 = <br/> Notice: Undefined index: customer- in /in/vgfI1 on line 5 customer-\0\0test2 = <br/>
Output for 7.3.32 - 7.3.33
customer-\0\0test1 = <br/>customer-\0\0test2 = <br/>

preferences:
230.13 ms | 401 KiB | 281 Q