3v4l.org

run code in 300+ PHP versions simultaneously
<?php $original = ['test' => 'test', 'test2'=>'another test', 'test3' => 'third test']; $address = ['test' => 'test', 'test2'=>'another test', 'test3' => 'third test diff', 'test4' => 'ignore me bro']; $changes = array_filter($original, function ($key, $data) use ($address) { return $data === $address->getData($key); }, ARRAY_FILTER_USE_BOTH); var_dump($changes);
Output for 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Fatal error: Uncaught Error: Call to a member function getData() on array in /in/9vLKU:8 Stack trace: #0 [internal function]: {closure}('test', 'test') #1 /in/9vLKU(7): array_filter(Array, Object(Closure), 1) #2 {main} thrown in /in/9vLKU on line 8
Process exited with code 255.
Output for 7.0.0 - 7.0.33, 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28
Fatal error: Uncaught Error: Call to a member function getData() on array in /in/9vLKU:8 Stack trace: #0 [internal function]: {closure}('test', 'test') #1 /in/9vLKU(9): array_filter(Array, Object(Closure), 1) #2 {main} thrown in /in/9vLKU on line 8
Process exited with code 255.
Output for 5.6.0 - 5.6.38
Fatal error: Call to a member function getData() on array in /in/9vLKU on line 8
Process exited with code 255.
Output for 5.4.0 - 5.4.45, 5.5.0 - 5.5.38
Notice: Use of undefined constant ARRAY_FILTER_USE_BOTH - assumed 'ARRAY_FILTER_USE_BOTH' in /in/9vLKU on line 9 Warning: array_filter() expects at most 2 parameters, 3 given in /in/9vLKU on line 9 NULL

preferences:
245.02 ms | 402 KiB | 340 Q