3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array1 = [1, 5, 10, 15, 22, 28]; $array2 = [1, 8, 12, 16, 25, 30]; $array3 = [10, 15, 20, 21, 22]; findVal([$array1, $array2, $array3], 15); function findVal($arrays = [], $needle) { foreach ($arrays as $key => $array) { foreach ($array as $value) { if ($value == $needle) { foreach ($GLOBALS as $arrayName => $value) { if ($value === $array) { echo 'value ' . $needle . ' found in : ' . $arrayName . "\r\n"; } } } } } }
Output for 8.4.1 - 8.4.18, 8.5.0 - 8.5.3
Deprecated: findVal(): Optional parameter $arrays declared before required parameter $needle is implicitly treated as a required parameter in /in/bCU2Z on line 8 value 15 found in : array1 value 15 found in : array3
Output for 8.1.0 - 8.1.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.30
Deprecated: Optional parameter $arrays declared before required parameter $needle is implicitly treated as a required parameter in /in/bCU2Z on line 8 value 15 found in : array1 value 15 found in : array3
Output for 8.0.0 - 8.0.30
Deprecated: Required parameter $needle follows optional parameter $arrays in /in/bCU2Z on line 8 value 15 found in : array1 value 15 found in : array3
Output for 7.1.26 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
value 15 found in : array1 value 15 found in : array3

preferences:
108.94 ms | 1535 KiB | 4 Q