3v4l.org

run code in 300+ PHP versions simultaneously
<?php // note the const declarations -- constants really read-only vars const COMMA = ','; const EMPTY_STR = ""; const NULL_CHAR = "\0"; $delim = '\n'; // note what happens when inserted into doubled-quoted string $data = "1,2,3,$delim,4,5,6,$delim,7,8,9"; echo "\nThe data is:\n\n$data\n\n"; var_dump( EMPTY_STR, NULL_CHAR,strcmp(EMPTY_STR, NULL_CHAR)); // "" != "\0" and "" !== "\0" echo "Is null char empty value? ",empty(NULL_CHAR)? 'true':'false',"\n"; echo "Is zero an empty value? ",empty(0)? 'true':'false',"\n"; $strNumsEtc = str_replace( COMMA, EMPTY_STR, $data); echo "\nResult: $strNumsEtc\n"; $strArr = explode( $delim, $strNumsEtc); $res = preg_split(/\\n/,$strNumsEtc); var_dump($res); foreach ($strArr as $str) { echo $str,PHP_EOL; // echo print both shades of echo: echo multiple vars, print one var plus retval } // must add the PHP_EOL since PHP doesn't automatically do this echo PHP_EOL; foreach ($strArr as $str) { print $str; print PHP_EOL; }

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
5.4.340.0060.03812.02
5.4.320.0100.04712.50
5.4.310.0160.09512.50
5.4.300.0100.04212.50
5.4.290.0120.07212.50
5.4.280.0120.04112.39
5.4.270.0060.04012.39
5.4.260.0130.05812.39
5.4.250.0140.05612.39
5.4.240.0100.04812.39
5.4.230.0060.04412.38
5.4.220.0070.03812.38
5.4.210.0060.03912.39
5.4.200.0050.05112.38
5.4.190.0070.04012.38
5.4.180.0070.04412.38
5.4.170.0070.04012.39
5.4.160.0120.03512.38
5.4.150.0070.03812.38
5.4.140.0050.04712.07
5.4.130.0050.03912.05
5.4.120.0050.04012.02
5.4.110.0070.03912.01
5.4.100.0050.03712.02
5.4.90.0050.03812.01
5.4.80.0080.03512.02
5.4.70.0070.03812.01
5.4.60.0080.04312.01
5.4.50.0070.06012.01
5.4.40.0060.04112.00
5.4.30.0060.03912.00
5.4.20.0050.03711.99
5.4.10.0050.03712.00
5.4.00.0140.03611.49
5.3.290.0060.04812.80
5.3.280.0060.04412.71
5.3.270.0040.04312.72
5.3.260.0030.04312.71
5.3.250.0040.04912.72
5.3.240.0110.04912.71
5.3.230.0070.04712.70
5.3.220.0130.05912.68
5.3.210.0110.06212.68
5.3.200.0090.04212.68
5.3.190.0090.04612.68
5.3.180.0080.03712.67
5.3.170.0080.04312.67
5.3.160.0100.03712.68
5.3.150.0070.04412.67
5.3.140.0070.05312.66
5.3.130.0110.06712.66
5.3.120.0110.04312.65
5.3.110.0080.04912.66
5.3.100.0080.04012.12
5.3.90.0070.04112.08
5.3.80.0080.04412.07
5.3.70.0130.04012.08
5.3.60.0110.04512.06
5.3.50.0080.04812.00
5.3.40.0120.04812.00
5.3.30.0090.04211.95
5.3.20.0060.04611.73
5.3.10.0080.04711.70
5.3.00.0040.04711.69
5.2.170.0050.0459.18
5.2.160.0150.0779.18
5.2.150.0050.0439.18
5.2.140.0050.0459.18
5.2.130.0040.0329.14
5.2.120.0040.0319.14
5.2.110.0050.0339.15
5.2.100.0090.0309.14
5.2.90.0040.0379.14
5.2.80.0070.0359.14
5.2.70.0080.0299.14
5.2.60.0060.0409.09
5.2.50.0080.0319.06
5.2.40.0070.0309.04
5.2.30.0060.0379.02
5.2.20.0060.0389.00
5.2.10.0160.0538.92
5.2.00.0070.0508.79
5.1.60.0110.0588.07
5.1.50.0070.0308.06
5.1.40.0070.0248.05
5.1.30.0040.0298.40
5.1.20.0120.0438.42
5.1.10.0080.0318.14
5.1.00.0040.0288.14
5.0.50.0030.0276.62
5.0.40.0080.0256.48
5.0.30.0080.0296.29
5.0.20.0070.0186.27
5.0.10.0050.0196.25
5.0.00.0040.0326.23
4.4.90.0040.0164.78
4.4.80.0060.0184.76
4.4.70.0010.0184.75
4.4.60.0030.0194.76
4.4.50.0060.0174.77
4.4.40.0040.0294.70
4.4.30.0060.0174.76
4.4.20.0060.0194.84
4.4.10.0050.0184.84
4.4.00.0030.0284.76
4.3.110.0010.0184.66
4.3.100.0050.0184.66
4.3.90.0050.0254.63
4.3.80.0050.0304.58
4.3.70.0170.0404.63
4.3.60.0070.0274.63
4.3.50.0040.0204.63
4.3.40.0070.0254.53
4.3.30.0030.0163.29
4.3.20.0020.0173.26
4.3.10.0070.0193.22
4.3.00.0030.0236.92

preferences:
139.46 ms | 1386 KiB | 7 Q