3v4l.org

run code in 500+ PHP versions simultaneously
<?php $variable[1] = ['A' => 'n', 'X' => 'n']; $variable[2] = ['A' => 'n', 'X' => 'Y']; $variable[3] = ['A' => 'B', 'X' => 'n']; $test = 'B'; $test2 = 'Y'; If(in_array($test, array_column($variable, "A"))){ Echo $test . " Found in A"; }Else if(in_array($test2, array_column($variable, "X"))){ Echo $test2 . " Found in B"; }else{ Echo "none found"; }
Output for 7.1.0 - 7.1.33, 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.34, 8.2.0 - 8.2.32, 8.3.0 - 8.3.32, 8.4.1 - 8.4.23, 8.5.0 - 8.5.8
B Found in A

preferences:
102.43 ms | 1601 KiB | 4 Q