3v4l.org

run code in 300+ PHP versions simultaneously
<?php $ar = Array ( 0 => "[", 1 => " [", 2 => " [", 3 => "Test", 4 => "Server1", 5 => null, 6 => "Server2", 7 => null, 8 => "", 9 => "stopped", 10 => " ]", 11 => " ]", 12 => "]", ); function cleanArray($ar){ $res = []; foreach($ar as $val){ preg_match ('/[\[\]]+/', $val, $matches); if(count($matches) == 0) $res[] = $val; } return $res; } $res = cleanArray($ar); print_r($res);
Output for 8.1.0 - 8.1.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.30, 8.4.1 - 8.4.14, 8.4.16 - 8.4.17, 8.5.0 - 8.5.2
Deprecated: preg_match(): Passing null to parameter #2 ($subject) of type string is deprecated in /in/8F1BI on line 24 Deprecated: preg_match(): Passing null to parameter #2 ($subject) of type string is deprecated in /in/8F1BI on line 24 Array ( [0] => Test [1] => Server1 [2] => [3] => Server2 [4] => [5] => [6] => stopped )
Output for 8.4.15
/bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.35' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.34' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15)
Process exited with code 1.
Output for 7.1.26 - 7.1.33, 7.2.17 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30
Array ( [0] => Test [1] => Server1 [2] => [3] => Server2 [4] => [5] => [6] => stopped )

preferences:
186.77 ms | 410 KiB | 5 Q