3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str = '1,"4052","B00K6ED81S",,"Bottle, white - 6,5 l, WENKO","Good design!","Bottle, white 6,5 l, WENKO",,,"item","23",23,"23",23,31.22,31.22,,1,,,,0,8,"4",,0,,0,0,,0,,0,0,0,,'; $pos=1; // set $pos to make sure while loop does not end directly. $newstr = ""; $prevPos = 0; $skip = false; // flag to know if replace should be done or not while($pos != false){ $pos = strpos($str, '"', $prevPos); // find " in string after prevPos $part = substr($str, $prevPos, $pos+1-$prevPos); // substring the part (first time it runs it will be '1,"' then '4052"') if($skip){ // if it's between two " (a string) skip the replace //echo "skip " . $part . "\n"; $skip =!$skip; // change the flag $newstr .= $part; }else{ // if it's not in a string do the replace on the $part //echo "!skip " . $part . "\n"; $newstr .= str_replace(",", ";", $part); $skip =!$skip; // change the flag. } $prevPos = $pos+1; // set new $prevPos } // if the loop ends and there is no more " in the string we need to replace , to ; on the rest of the string. // we know the loop ended at strlen($newstr), so that is the $part. if($pos<strlen($str)) $newstr .= str_replace(",", ";", substr($str, strlen($newstr))); echo $str . "\n"; echo $newstr;

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)
8.3.60.0070.01418.31
8.3.50.0040.01116.46
8.3.40.0060.01018.84
8.3.30.0120.00318.71
8.3.20.0070.00720.29
8.3.10.0040.00420.91
8.3.00.0030.00519.46
8.2.180.0070.00716.50
8.2.170.0030.01022.96
8.2.160.0030.01320.52
8.2.150.0050.00324.18
8.2.140.0080.00024.66
8.2.130.0070.00022.25
8.2.120.0050.00326.35
8.2.110.0070.00421.95
8.2.100.0080.00317.97
8.2.90.0000.00819.34
8.2.80.0040.00417.97
8.2.70.0000.00817.75
8.2.60.0080.00317.80
8.2.50.0060.00318.07
8.2.40.0000.00818.10
8.2.30.0040.00418.02
8.2.20.0020.00518.14
8.2.10.0040.00418.16
8.2.00.0000.00718.03
8.1.280.0120.00925.92
8.1.270.0110.00422.14
8.1.260.0070.00026.35
8.1.250.0040.00428.09
8.1.240.0030.00720.72
8.1.230.0090.00320.85
8.1.220.0040.00417.77
8.1.210.0040.00418.77
8.1.200.0060.00317.22
8.1.190.0050.00317.23
8.1.180.0000.00818.10
8.1.170.0040.00418.95
8.1.160.0000.00718.85
8.1.150.0030.00518.89
8.1.140.0050.00319.59
8.1.130.0030.00318.83
8.1.120.0070.00017.43
8.1.110.0040.00417.49
8.1.100.0040.00417.45
8.1.90.0000.00817.48
8.1.80.0040.00417.48
8.1.70.0030.00317.48
8.1.60.0030.00617.51
8.1.50.0040.00417.55
8.1.40.0050.00517.45
8.1.30.0040.00417.70
8.1.20.0000.00717.66
8.1.10.0060.00317.45
8.1.00.0050.00317.31
8.0.300.0050.00518.77
8.0.290.0080.00016.63
8.0.280.0070.00018.50
8.0.270.0070.00017.27
8.0.260.0050.00318.84
8.0.250.0030.00316.92
8.0.240.0000.00716.90
8.0.230.0000.00816.94
8.0.220.0070.00316.98
8.0.210.0040.00416.96
8.0.200.0030.00316.91
8.0.190.0040.00416.95
8.0.180.0000.00717.01
8.0.170.0000.00716.96
8.0.160.0070.00016.93
8.0.150.0000.00816.96
8.0.140.0030.00316.82
8.0.130.0000.00513.35
8.0.120.0030.00616.90
8.0.110.0050.00216.98
8.0.100.0050.00316.91
8.0.90.0000.00816.83
8.0.80.0060.00916.89
8.0.70.0070.00017.02
8.0.60.0040.00416.79
8.0.50.0050.00316.84
8.0.30.0100.00817.12
8.0.20.0110.00717.41
8.0.10.0040.00416.99
8.0.00.0030.01716.75
7.4.330.0020.00215.55
7.4.320.0030.00316.51
7.4.300.0000.00616.58
7.4.290.0030.00316.60
7.4.280.0040.00416.55
7.4.270.0000.00816.52
7.4.260.0050.00316.40
7.4.250.0000.00816.53
7.4.240.0000.00916.41
7.4.230.0000.00716.63
7.4.220.0030.01416.55
7.4.210.0060.01116.54
7.4.200.0030.00516.49
7.4.160.0120.00516.48
7.4.150.0040.01417.40
7.4.140.0100.00717.86
7.4.130.0090.01516.52
7.4.120.0100.00916.53
7.4.110.0140.00316.48
7.4.100.0140.00316.56
7.4.90.0120.00616.61
7.4.80.0030.01319.39
7.4.70.0080.01216.37
7.4.60.0070.01316.46
7.4.50.0040.00816.67
7.4.40.0130.00916.68
7.4.30.0130.00316.55
7.4.00.0150.00314.71
7.3.330.0000.00613.10
7.3.320.0030.00313.19
7.3.310.0000.00716.22
7.3.300.0000.00716.27
7.3.290.0140.00616.21
7.3.280.0110.00616.25
7.3.270.0080.00817.40
7.3.260.0100.00816.41
7.3.250.0090.00916.39
7.3.240.0080.01016.29
7.3.230.0060.01216.22
7.3.210.0090.00916.42
7.3.200.0100.00716.48
7.3.190.0060.01216.48
7.3.180.0160.00616.59
7.3.170.0040.01416.45
7.3.160.0130.00316.34
7.2.330.0070.01116.52
7.2.320.0130.00916.51
7.2.310.0060.01216.80
7.2.300.0030.01716.56
7.2.290.0140.00316.70
7.2.110.0190.01016.43
7.2.60.0070.00716.93
7.1.200.0200.00815.24
7.1.80.0070.00718.26
7.1.70.0280.01017.27
7.1.60.0210.01034.80
7.1.50.0190.01334.87
7.1.40.0180.01234.61
7.1.30.0200.01034.64
7.1.20.0240.01634.42
7.1.10.0090.00616.61
7.1.00.0060.00816.72
7.0.200.0060.01216.68
7.0.190.0040.01316.82
7.0.180.0080.00916.34
7.0.170.0030.01516.20
7.0.160.0040.01416.18
7.0.150.0030.01616.30
7.0.140.0080.00916.26
7.0.130.0030.01516.80
7.0.120.0000.01816.48
7.0.110.0100.01016.13
7.0.100.0130.00816.55
7.0.90.0030.01316.50
7.0.80.0040.01416.66
7.0.70.0060.01016.43
7.0.60.0090.00616.29
7.0.50.0050.01316.37
7.0.40.0100.00616.43
7.0.30.0020.01616.48
7.0.20.0030.01416.43
7.0.10.0080.00916.59
7.0.00.0060.01216.59

preferences:
48.71 ms | 400 KiB | 5 Q