3v4l.org

run code in 300+ PHP versions simultaneously
<?php $mlbCities = array( 'Carolina', 'Atlanta', 'New Orleans', 'Philadelphia', 'St. Louis', 'Washington', 'Houston', 'Tennessee', 'New England', 'NY Jets', 'Cincinnati', 'Green Bay', 'Arizona', 'Jacksonville', 'Oakland', 'Kansas City', 'Minnesota', 'Detroit', 'Tampa Bay', 'Buffalo', 'Seattle', 'San Francisco', 'Pittsburgh', 'Chicago', 'Baltimore', 'San Diego', 'Cleveland', 'Denver', 'NY Giants', 'Dallas', 'Indianapolis', 'Miami' ); $string = 'San Francisco Giants'; foreach($mlbCities as $city) { $fl_array[] = preg_grep("/$city/", $string); } var_dump($fl_array); ?>
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.27, 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
Fatal error: Uncaught TypeError: preg_grep(): Argument #2 ($array) must be of type array, string given in /in/6kRGF:40 Stack trace: #0 /in/6kRGF(40): preg_grep('/Carolina/', 'San Francisco G...') #1 {main} thrown in /in/6kRGF on line 40
Process exited with code 255.
Output for 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.12 - 7.3.33, 7.4.0 - 7.4.33
Warning: preg_grep() expects parameter 2 to be array, string given in /in/6kRGF on line 40 Warning: preg_grep() expects parameter 2 to be array, string given in /in/6kRGF on line 40 Warning: preg_grep() expects parameter 2 to be array, string given in /in/6kRGF on line 40 Warning: preg_grep() expects parameter 2 to be array, string given in /in/6kRGF on line 40 Warning: preg_grep() expects parameter 2 to be array, string given in /in/6kRGF on line 40 Warning: preg_grep() expects parameter 2 to be array, string given in /in/6kRGF on line 40 Warning: preg_grep() expects parameter 2 to be array, string given in /in/6kRGF on line 40 Warning: preg_grep() expects parameter 2 to be array, string given in /in/6kRGF on line 40 Warning: preg_grep() expects parameter 2 to be array, string given in /in/6kRGF on line 40 Warning: preg_grep() expects parameter 2 to be array, string given in /in/6kRGF on line 40 Warning: preg_grep() expects parameter 2 to be array, string given in /in/6kRGF on line 40 Warning: preg_grep() expects parameter 2 to be array, string given in /in/6kRGF on line 40 Warning: preg_grep() expects parameter 2 to be array, string given in /in/6kRGF on line 40 Warning: preg_grep() expects parameter 2 to be array, string given in /in/6kRGF on line 40 Warning: preg_grep() expects parameter 2 to be array, string given in /in/6kRGF on line 40 Warning: preg_grep() expects parameter 2 to be array, string given in /in/6kRGF on line 40 Warning: preg_grep() expects parameter 2 to be array, string given in /in/6kRGF on line 40 Warning: preg_grep() expects parameter 2 to be array, string given in /in/6kRGF on line 40 Warning: preg_grep() expects parameter 2 to be array, string given in /in/6kRGF on line 40 Warning: preg_grep() expects parameter 2 to be array, string given in /in/6kRGF on line 40 Warning: preg_grep() expects parameter 2 to be array, string given in /in/6kRGF on line 40 Warning: preg_grep() expects parameter 2 to be array, string given in /in/6kRGF on line 40 Warning: preg_grep() expects parameter 2 to be array, string given in /in/6kRGF on line 40 Warning: preg_grep() expects parameter 2 to be array, string given in /in/6kRGF on line 40 Warning: preg_grep() expects parameter 2 to be array, string given in /in/6kRGF on line 40 Warning: preg_grep() expects parameter 2 to be array, string given in /in/6kRGF on line 40 Warning: preg_grep() expects parameter 2 to be array, string given in /in/6kRGF on line 40 Warning: preg_grep() expects parameter 2 to be array, string given in /in/6kRGF on line 40 Warning: preg_grep() expects parameter 2 to be array, string given in /in/6kRGF on line 40 Warning: preg_grep() expects parameter 2 to be array, string given in /in/6kRGF on line 40 Warning: preg_grep() expects parameter 2 to be array, string given in /in/6kRGF on line 40 Warning: preg_grep() expects parameter 2 to be array, string given in /in/6kRGF on line 40 array(32) { [0]=> NULL [1]=> NULL [2]=> NULL [3]=> NULL [4]=> NULL [5]=> NULL [6]=> NULL [7]=> NULL [8]=> NULL [9]=> NULL [10]=> NULL [11]=> NULL [12]=> NULL [13]=> NULL [14]=> NULL [15]=> NULL [16]=> NULL [17]=> NULL [18]=> NULL [19]=> NULL [20]=> NULL [21]=> NULL [22]=> NULL [23]=> NULL [24]=> NULL [25]=> NULL [26]=> NULL [27]=> NULL [28]=> NULL [29]=> NULL [30]=> NULL [31]=> NULL }
Output for 4.3.11, 4.4.0 - 4.4.9, 5.0.0 - 5.0.5, 5.1.0 - 5.1.6
Warning: preg_grep(): Second argument to preg_grep() should be an array in /in/6kRGF on line 40 Warning: preg_grep(): Second argument to preg_grep() should be an array in /in/6kRGF on line 40 Warning: preg_grep(): Second argument to preg_grep() should be an array in /in/6kRGF on line 40 Warning: preg_grep(): Second argument to preg_grep() should be an array in /in/6kRGF on line 40 Warning: preg_grep(): Second argument to preg_grep() should be an array in /in/6kRGF on line 40 Warning: preg_grep(): Second argument to preg_grep() should be an array in /in/6kRGF on line 40 Warning: preg_grep(): Second argument to preg_grep() should be an array in /in/6kRGF on line 40 Warning: preg_grep(): Second argument to preg_grep() should be an array in /in/6kRGF on line 40 Warning: preg_grep(): Second argument to preg_grep() should be an array in /in/6kRGF on line 40 Warning: preg_grep(): Second argument to preg_grep() should be an array in /in/6kRGF on line 40 Warning: preg_grep(): Second argument to preg_grep() should be an array in /in/6kRGF on line 40 Warning: preg_grep(): Second argument to preg_grep() should be an array in /in/6kRGF on line 40 Warning: preg_grep(): Second argument to preg_grep() should be an array in /in/6kRGF on line 40 Warning: preg_grep(): Second argument to preg_grep() should be an array in /in/6kRGF on line 40 Warning: preg_grep(): Second argument to preg_grep() should be an array in /in/6kRGF on line 40 Warning: preg_grep(): Second argument to preg_grep() should be an array in /in/6kRGF on line 40 Warning: preg_grep(): Second argument to preg_grep() should be an array in /in/6kRGF on line 40 Warning: preg_grep(): Second argument to preg_grep() should be an array in /in/6kRGF on line 40 Warning: preg_grep(): Second argument to preg_grep() should be an array in /in/6kRGF on line 40 Warning: preg_grep(): Second argument to preg_grep() should be an array in /in/6kRGF on line 40 Warning: preg_grep(): Second argument to preg_grep() should be an array in /in/6kRGF on line 40 Warning: preg_grep(): Second argument to preg_grep() should be an array in /in/6kRGF on line 40 Warning: preg_grep(): Second argument to preg_grep() should be an array in /in/6kRGF on line 40 Warning: preg_grep(): Second argument to preg_grep() should be an array in /in/6kRGF on line 40 Warning: preg_grep(): Second argument to preg_grep() should be an array in /in/6kRGF on line 40 Warning: preg_grep(): Second argument to preg_grep() should be an array in /in/6kRGF on line 40 Warning: preg_grep(): Second argument to preg_grep() should be an array in /in/6kRGF on line 40 Warning: preg_grep(): Second argument to preg_grep() should be an array in /in/6kRGF on line 40 Warning: preg_grep(): Second argument to preg_grep() should be an array in /in/6kRGF on line 40 Warning: preg_grep(): Second argument to preg_grep() should be an array in /in/6kRGF on line 40 Warning: preg_grep(): Second argument to preg_grep() should be an array in /in/6kRGF on line 40 Warning: preg_grep(): Second argument to preg_grep() should be an array in /in/6kRGF on line 40 array(32) { [0]=> NULL [1]=> NULL [2]=> NULL [3]=> NULL [4]=> NULL [5]=> NULL [6]=> NULL [7]=> NULL [8]=> NULL [9]=> NULL [10]=> NULL [11]=> NULL [12]=> NULL [13]=> NULL [14]=> NULL [15]=> NULL [16]=> NULL [17]=> NULL [18]=> NULL [19]=> NULL [20]=> NULL [21]=> NULL [22]=> NULL [23]=> NULL [24]=> NULL [25]=> NULL [26]=> NULL [27]=> NULL [28]=> NULL [29]=> NULL [30]=> NULL [31]=> NULL }
Output for 4.3.0 - 4.3.10
Warning: Second argument to preg_grep() should be an array in /in/6kRGF on line 40 Warning: Second argument to preg_grep() should be an array in /in/6kRGF on line 40 Warning: Second argument to preg_grep() should be an array in /in/6kRGF on line 40 Warning: Second argument to preg_grep() should be an array in /in/6kRGF on line 40 Warning: Second argument to preg_grep() should be an array in /in/6kRGF on line 40 Warning: Second argument to preg_grep() should be an array in /in/6kRGF on line 40 Warning: Second argument to preg_grep() should be an array in /in/6kRGF on line 40 Warning: Second argument to preg_grep() should be an array in /in/6kRGF on line 40 Warning: Second argument to preg_grep() should be an array in /in/6kRGF on line 40 Warning: Second argument to preg_grep() should be an array in /in/6kRGF on line 40 Warning: Second argument to preg_grep() should be an array in /in/6kRGF on line 40 Warning: Second argument to preg_grep() should be an array in /in/6kRGF on line 40 Warning: Second argument to preg_grep() should be an array in /in/6kRGF on line 40 Warning: Second argument to preg_grep() should be an array in /in/6kRGF on line 40 Warning: Second argument to preg_grep() should be an array in /in/6kRGF on line 40 Warning: Second argument to preg_grep() should be an array in /in/6kRGF on line 40 Warning: Second argument to preg_grep() should be an array in /in/6kRGF on line 40 Warning: Second argument to preg_grep() should be an array in /in/6kRGF on line 40 Warning: Second argument to preg_grep() should be an array in /in/6kRGF on line 40 Warning: Second argument to preg_grep() should be an array in /in/6kRGF on line 40 Warning: Second argument to preg_grep() should be an array in /in/6kRGF on line 40 Warning: Second argument to preg_grep() should be an array in /in/6kRGF on line 40 Warning: Second argument to preg_grep() should be an array in /in/6kRGF on line 40 Warning: Second argument to preg_grep() should be an array in /in/6kRGF on line 40 Warning: Second argument to preg_grep() should be an array in /in/6kRGF on line 40 Warning: Second argument to preg_grep() should be an array in /in/6kRGF on line 40 Warning: Second argument to preg_grep() should be an array in /in/6kRGF on line 40 Warning: Second argument to preg_grep() should be an array in /in/6kRGF on line 40 Warning: Second argument to preg_grep() should be an array in /in/6kRGF on line 40 Warning: Second argument to preg_grep() should be an array in /in/6kRGF on line 40 Warning: Second argument to preg_grep() should be an array in /in/6kRGF on line 40 Warning: Second argument to preg_grep() should be an array in /in/6kRGF on line 40 array(32) { [0]=> NULL [1]=> NULL [2]=> NULL [3]=> NULL [4]=> NULL [5]=> NULL [6]=> NULL [7]=> NULL [8]=> NULL [9]=> NULL [10]=> NULL [11]=> NULL [12]=> NULL [13]=> NULL [14]=> NULL [15]=> NULL [16]=> NULL [17]=> NULL [18]=> NULL [19]=> NULL [20]=> NULL [21]=> NULL [22]=> NULL [23]=> NULL [24]=> NULL [25]=> NULL [26]=> NULL [27]=> NULL [28]=> NULL [29]=> NULL [30]=> NULL [31]=> NULL }

preferences:
303.9 ms | 409 KiB | 355 Q