3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Arrays { /** * Replaces in all strings within a multidimensional array, even if objects are included * @param string $search search for this string * @param string $replace_with replace with this string * @param mixed $haystack Array or Object to search in all elements * @return mixed gives the same structure back */ public static function replace_everywhere($search, $replace_with, $haystack) { if (is_array($haystack) or is_object($haystack)) { // Arrays and Objects foreach ($haystack as &$value) { $value = Arrays::replace_everywhere($search, $replace_with, $value); } return $haystack; } elseif (is_string($haystack)) { // replace in a string element return str_replace($search, $replace_with, $haystack); } else { // other datatypes (e.g. integer) stay untouched return $haystack; } } } // You can call this like e.g. $a = array(true, 1, 'foo<bar', 'foo<baz', array("foo<loo"), (object) array('1' => 'foo<boo')); $a = Arrays::replace_everywhere("<", "&lt;", $a); var_export($a);

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.4.130.0140.00617.77
8.4.120.0130.00722.33
8.4.110.0140.00622.44
8.4.100.0140.00617.64
8.4.90.0130.00720.45
8.4.80.0070.00817.89
8.4.70.0050.00317.81
8.4.60.0120.01118.70
8.4.50.0140.00618.62
8.4.40.0030.00620.46
8.4.30.0100.01018.63
8.4.20.0160.00618.08
8.4.10.0100.01023.71
8.3.260.0050.00316.56
8.3.250.0090.01018.82
8.3.240.0120.00516.54
8.3.230.0090.01116.67
8.3.220.0070.00217.13
8.3.210.0080.00116.73
8.3.200.0150.00216.62
8.3.190.0050.01219.02
8.3.180.0120.00616.41
8.3.170.0160.00317.07
8.3.160.0110.00318.43
8.3.150.0070.01116.72
8.3.140.0040.01116.76
8.3.130.0030.00618.36
8.3.120.0060.00318.29
8.3.110.0090.00616.63
8.3.100.0040.01116.63
8.3.90.0120.00616.53
8.3.80.0000.01118.55
8.3.70.0120.00318.55
8.3.60.0070.01516.50
8.3.50.0160.00616.42
8.3.40.0100.00722.23
8.3.30.0120.00318.85
8.3.20.0040.00424.18
8.3.10.0080.00024.66
8.3.00.0070.00026.16
8.2.290.0100.00822.72
8.2.280.0100.00918.14
8.2.270.0050.00317.38
8.2.260.0100.00016.68
8.2.250.0090.00316.91
8.2.240.0060.00317.38
8.2.230.0070.00320.94
8.2.220.0060.00924.06
8.2.210.0190.00026.77
8.2.200.0030.00618.41
8.2.190.0080.00616.63
8.2.180.0070.00716.63
8.2.170.0110.00418.96
8.2.160.0030.01022.96
8.2.150.0050.00325.66
8.2.140.0000.00724.66
8.2.130.0000.00726.16
8.2.120.0040.00419.95
8.2.110.0030.00622.16
8.2.100.0060.00320.31
8.2.50.0050.00417.87
8.1.330.0090.01122.04
8.1.320.0110.00816.16
8.1.310.0070.00018.42
8.1.300.0150.00420.30
8.1.290.0040.00818.88
8.1.280.0110.00325.92
8.1.270.0000.00824.66
8.1.260.0070.00026.35
8.1.250.0030.00628.09
8.1.240.0070.00318.50
8.1.230.0060.00318.57
8.1.170.0040.00417.55

preferences:
27.82 ms | 403 KiB | 5 Q