3v4l.org

run code in 300+ PHP versions simultaneously
<?php $tests = [null, 0, '0', '', 'a', 'b,c,d', '1,2,3,4']; foreach ($tests as $test) { var_dump($test); echo " -> \n"; var_export(explode(',', $test)); echo "\n---\n"; }
Output for 8.1.0 - 8.1.13
NULL -> Deprecated: explode(): Passing null to parameter #2 ($string) of type string is deprecated in /in/b55r5 on line 7 array ( 0 => '', ) --- int(0) -> array ( 0 => '0', ) --- string(1) "0" -> array ( 0 => '0', ) --- string(0) "" -> array ( 0 => '', ) --- string(1) "a" -> array ( 0 => 'a', ) --- string(5) "b,c,d" -> array ( 0 => 'b', 1 => 'c', 2 => 'd', ) --- string(7) "1,2,3,4" -> array ( 0 => '1', 1 => '2', 2 => '3', 3 => '4', ) ---
Output for 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.26
NULL -> array ( 0 => '', ) --- int(0) -> array ( 0 => '0', ) --- string(1) "0" -> array ( 0 => '0', ) --- string(0) "" -> array ( 0 => '', ) --- string(1) "a" -> array ( 0 => 'a', ) --- string(5) "b,c,d" -> array ( 0 => 'b', 1 => 'c', 2 => 'd', ) --- string(7) "1,2,3,4" -> array ( 0 => '1', 1 => '2', 2 => '3', 3 => '4', ) ---

preferences:
65.71 ms | 412 KiB | 5 Q