3v4l.org

run code in 300+ PHP versions simultaneously
<?php $environments = [ 'qa-only' => [], 'prd-only' => [], 'both' => [] ]; $qa = file('qa.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); $prd = file('prd.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); foreach($prd as $key => $env) { if(in_array($env, $qa)) { $environments['both'][] = $env; } else { $environments['prd-only'][] = $env; } } foreach($qa as $key => $env) { if(in_array($env, $prd) && !in_array($env, $environments['both'])) { $environments['both'][] = $env; } else { $environments['qa-only'][] = $env; } } print_r($environments);
Output for 8.3.0 - 8.3.3
Warning: file(): open_basedir restriction in effect. File(qa.txt) is not within the allowed path(s): (/tmp:/in:/etc) in /in/FEtvh on line 9 Warning: file(qa.txt): Failed to open stream: Operation not permitted in /in/FEtvh on line 9 Warning: file(): open_basedir restriction in effect. File(prd.txt) is not within the allowed path(s): (/tmp:/in:/etc) in /in/FEtvh on line 10 Warning: file(prd.txt): Failed to open stream: Operation not permitted in /in/FEtvh on line 10 Warning: foreach() argument must be of type array|object, false given in /in/FEtvh on line 12 Warning: foreach() argument must be of type array|object, false given in /in/FEtvh on line 20 Array ( [qa-only] => Array ( ) [prd-only] => Array ( ) [both] => Array ( ) )
Output for 8.1.0 - 8.1.27, 8.2.0 - 8.2.16
Warning: file(): open_basedir restriction in effect. File(qa.txt) is not within the allowed path(s): (/tmp:/in:/etc) in /in/FEtvh on line 9 Warning: file(qa.txt): Failed to open stream: Operation not permitted in /in/FEtvh on line 9 Warning: file(): open_basedir restriction in effect. File(prd.txt) is not within the allowed path(s): (/tmp:/in:/etc) in /in/FEtvh on line 10 Warning: file(prd.txt): Failed to open stream: Operation not permitted in /in/FEtvh on line 10 Warning: foreach() argument must be of type array|object, bool given in /in/FEtvh on line 12 Warning: foreach() argument must be of type array|object, bool given in /in/FEtvh on line 20 Array ( [qa-only] => Array ( ) [prd-only] => Array ( ) [both] => Array ( ) )

preferences:
64.22 ms | 404 KiB | 54 Q