3v4l.org

run code in 300+ PHP versions simultaneously
<?php defined('BASEPATH') OR exit('No direct script access allowed'); class CI_Parser { /** * Left delimeter character for psuedo vars * * @var string */ public $l_delim = '{'; /** * Right delimeter character for psuedo vars * * @var string */ public $r_delim = '}'; /** * Reference to CodeIgniter instance * * @var object */ protected $CI; // -------------------------------------------------------------------- /** * Class constructor * * @return void */ public function __construct() { $this->CI =& get_instance(); } // -------------------------------------------------------------------- /** * Parse a template * * Parses pseudo-variables contained in the specified template view, * replacing them with the data in the second param * * @param string * @param array * @param bool * @return string */ public function parse($template, $data, $return = FALSE) { $template = $this->CI->load->view($template, $data, TRUE); return $this->_parse($template, $data, $return); } // -------------------------------------------------------------------- /** * Parse a String * * Parses pseudo-variables contained in the specified string, * replacing them with the data in the second param * * @param string * @param array * @param bool * @return string */ public function parse_string($template, $data, $return = FALSE) { return $this->_parse($template, $data, $return); } // -------------------------------------------------------------------- /** * Parse a template * * Parses pseudo-variables contained in the specified template, * replacing them with the data in the second param * * @param string * @param array * @param bool * @return string */ protected function _parse($template, $data, $return = FALSE) { if ($template === '') { return FALSE; } foreach ($data as $key => $val) { $template = is_array($val) ? $this->_parse_pair($key, $val, $template) : $template = $this->_parse_single($key, (string) $val, $template); } if ($return === FALSE) { $this->CI->output->append_output($template); } return $template; } // -------------------------------------------------------------------- /** * Set the left/right variable delimiters * * @param string * @param string * @return void */ public function set_delimiters($l = '{', $r = '}') { $this->l_delim = $l; $this->r_delim = $r; } // -------------------------------------------------------------------- /** * Parse a single key/value * * @param string * @param string * @param string * @return string */ protected function _parse_single($key, $val, $string) { return str_replace($this->l_delim.$key.$this->r_delim, (string) $val, $string); } // -------------------------------------------------------------------- /** * Parse a tag pair * * Parses tag pairs: {some_tag} string... {/some_tag} * * @param string * @param array * @param string * @return string */ protected function _parse_pair($variable, $data, $string) { if (FALSE === ($match = $this->_match_pair($string, $variable))) { return $string; } $str = ''; foreach ($data as $row) { $temp = $match[1]; foreach ($row as $key => $val) { $temp = is_array($val) ? $this->_parse_pair($key, $val, $temp) : $this->_parse_single($key, $val, $temp); } $str .= $temp; } return str_replace($match[0], $str, $string); } // -------------------------------------------------------------------- /** * Matches a variable pair * * @param string * @param string * @return mixed */ protected function _match_pair($string, $variable) { return preg_match('|'.preg_quote($this->l_delim).$variable.preg_quote($this->r_delim).'(.+?)'.preg_quote($this->l_delim).'/'.$variable.preg_quote($this->r_delim).'|s', $string, $match) ? $match : FALSE; } }

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.0140.00718.51
8.3.50.0090.01021.98
8.3.40.0110.00418.78
8.3.30.0040.01118.71
8.3.20.0080.00018.65
8.3.10.0040.00420.92
8.3.00.0080.00023.65
8.2.180.0120.00616.63
8.2.170.0110.00422.96
8.2.160.0110.00420.39
8.2.150.0040.00424.18
8.2.140.0040.00424.66
8.2.130.0040.00426.16
8.2.120.0040.00420.95
8.2.110.0000.00920.53
8.2.100.0040.00717.91
8.2.90.0040.00419.22
8.2.80.0030.00517.97
8.2.70.0040.00817.75
8.2.60.0050.00518.01
8.2.50.0070.00318.07
8.2.40.0060.00318.09
8.2.30.0000.00919.57
8.2.20.0030.00617.72
8.2.10.0050.00317.81
8.2.00.0040.00417.75
8.1.280.0090.00925.92
8.1.270.0080.00023.99
8.1.260.0090.00626.35
8.1.250.0080.00028.09
8.1.240.0070.00322.47
8.1.230.0000.01221.09
8.1.220.0040.00418.77
8.1.210.0030.00519.16
8.1.200.0040.00417.47
8.1.190.0050.00317.40
8.1.180.0000.00818.10
8.1.170.0050.00520.25
8.1.160.0040.00418.90
8.1.150.0000.00818.70
8.1.140.0000.00717.54
8.1.130.0000.00817.80
8.1.120.0000.00717.47
8.1.110.0030.00517.43
8.1.100.0000.00717.37
8.1.90.0040.00417.51
8.1.80.0040.00417.37
8.1.70.0070.00017.41
8.1.60.0060.00317.47
8.1.50.0050.00317.48
8.1.40.0040.00417.61
8.1.30.0040.00417.55
8.1.20.0030.00617.49
8.1.10.0030.00517.50
8.1.00.0060.00317.44
8.0.300.0040.00420.07
8.0.290.0030.00517.16
8.0.280.0030.00318.45
8.0.270.0000.00717.27
8.0.260.0080.00016.85
8.0.250.0040.00416.99
8.0.240.0050.00316.92
8.0.230.0050.00216.99
8.0.220.0100.00016.97
8.0.210.0070.00016.94
8.0.200.0030.00317.05
8.0.190.0000.00916.96
8.0.180.0000.00716.95
8.0.170.0070.00016.90
8.0.160.0100.00016.93
8.0.150.0040.00416.95
8.0.140.0030.00616.96
8.0.130.0060.00013.33
8.0.120.0000.00816.97
8.0.110.0050.00316.82
8.0.100.0000.00716.84
8.0.90.0050.00216.97
8.0.80.0040.01116.98
8.0.70.0070.00016.78
8.0.60.0000.00816.94
8.0.50.0050.00216.82
8.0.30.0120.01217.18
8.0.20.0120.00717.40
8.0.10.0000.00717.06
8.0.00.0120.00516.82
7.4.330.0060.00016.77
7.4.320.0030.00316.51
7.4.300.0030.00316.41
7.4.290.0030.00316.60
7.4.280.0030.00316.50
7.4.270.0070.00016.52
7.4.260.0000.00513.25
7.4.250.0000.00816.43
7.4.240.0060.00316.62
7.4.230.0050.00216.36
7.4.220.0130.00316.62
7.4.210.0120.00516.56
7.4.200.0040.00416.40
7.4.190.0030.00516.54
7.4.160.0100.00616.50
7.4.150.0170.00717.40
7.4.140.0090.00917.86
7.4.130.0090.01016.54
7.4.120.0130.00516.52
7.4.110.0050.01216.66
7.4.100.0180.00016.39
7.4.90.0110.00716.60
7.4.80.0150.00919.39
7.4.70.0140.00316.49
7.4.60.0070.01016.43
7.4.50.0030.00316.20
7.4.40.0000.01722.77
7.4.30.0100.00916.66
7.4.00.0070.01014.90
7.3.330.0050.00013.24
7.3.320.0000.00513.11
7.3.310.0040.00416.13
7.3.300.0030.00316.33
7.3.290.0090.00616.31
7.3.280.0080.00816.25
7.3.270.0100.00717.40
7.3.260.0090.00818.24
7.3.250.0130.00516.50
7.3.240.0060.01016.46
7.3.230.0100.00716.39
7.3.210.0270.01716.53
7.3.200.0080.00819.39
7.3.190.0110.00516.37
7.3.180.0070.01016.31
7.3.170.0100.00716.57
7.3.160.0140.00216.61
7.3.120.0100.00714.55
7.3.110.0100.00714.71
7.3.100.0060.01314.93
7.3.90.0100.00314.79
7.3.80.0070.00714.80
7.3.70.0120.00414.64
7.3.60.0060.00914.84
7.3.50.0090.00614.68
7.3.40.0000.01614.82
7.3.30.0120.00314.87
7.3.20.0030.01316.64
7.3.10.0000.00916.53
7.3.00.0070.00416.43
7.2.330.0070.01116.69
7.2.320.0070.01016.55
7.2.310.0120.00916.75
7.2.300.0040.01816.49
7.2.290.0140.00316.45
7.2.250.0040.01514.85
7.2.240.0040.01514.68
7.2.230.0090.00914.95
7.2.220.0060.00615.02
7.2.210.0030.00915.07
7.2.200.0070.00715.08
7.2.190.0070.01114.96
7.2.180.0060.01015.02
7.2.170.0060.00315.05
7.2.60.0090.00616.86
7.2.00.0030.00919.36
7.1.330.0120.00315.68
7.1.320.0070.00715.55
7.1.310.0040.00815.81
7.1.300.0050.00515.67
7.1.290.0030.00915.89
7.1.280.0040.00815.81
7.1.270.0080.00315.65
7.1.260.0060.00915.40
7.1.200.0100.00315.64
7.1.100.0060.00618.18
7.1.70.0000.00717.00
7.1.60.0070.00317.22
7.1.50.0100.01016.96
7.1.00.0000.03722.33
7.0.200.0070.01016.73
7.0.140.0030.07322.09
7.0.60.0170.07719.98
7.0.50.0030.05717.89
7.0.40.0100.08020.02
7.0.30.0600.06320.13
7.0.20.0270.06320.22
7.0.10.0070.08720.22
7.0.00.0100.05320.09
5.6.280.0030.07320.93
5.6.210.0000.04320.58
5.6.200.0070.05318.19
5.6.190.0000.06720.39
5.6.180.0470.07020.50
5.6.170.0270.05320.39
5.6.160.0070.08020.57
5.6.150.0100.08018.16
5.6.140.0070.08018.17
5.6.130.0100.07018.21
5.6.120.0070.08721.04
5.6.110.0100.08021.02
5.6.100.0130.06320.91
5.6.90.0130.05321.02
5.6.80.0170.07320.43
5.5.350.0330.08720.43
5.5.340.0070.08018.08
5.5.330.0100.08020.40
5.5.320.0330.03720.35
5.5.310.0200.07320.19
5.5.300.0030.05017.95
5.5.290.0100.03318.04
5.5.280.0100.08320.98
5.5.270.0130.07720.70
5.5.260.0000.08720.89
5.5.250.0300.06020.80
5.5.240.0270.03320.21
5.4.450.0370.03719.48
5.4.440.0300.04319.27
5.4.430.0430.04319.52
5.4.420.0470.04019.64
5.4.410.0470.06719.15
5.4.400.0400.07019.00
5.4.390.0430.04319.16
5.4.380.0400.04319.22
5.4.370.0470.06019.22
5.4.360.0430.06018.87
5.4.350.0470.05719.22
5.4.340.0430.04719.25
5.4.320.0470.06318.95
5.4.310.0370.03719.00
5.4.300.0470.04319.19
5.4.290.0470.06318.99
5.4.280.0470.04319.31
5.4.270.0400.03319.06
5.4.260.0400.05319.22
5.4.250.0330.04319.14
5.4.240.0330.05019.07
5.4.230.0400.04718.99
5.4.220.0370.05019.24
5.4.210.0430.03319.24
5.4.200.0330.04019.16
5.4.190.0470.07019.12
5.4.180.0430.03019.30
5.4.170.0470.07319.20
5.4.160.0400.04719.20
5.4.150.0370.03719.20
5.4.140.0370.03716.39
5.4.130.0330.04716.34
5.4.120.0400.04316.33
5.4.110.0370.03716.51
5.4.100.0370.03716.45
5.4.90.0300.04016.52
5.4.80.0330.06316.53
5.4.70.0400.03016.40
5.4.60.0370.04716.53
5.4.50.0470.03716.24
5.4.40.0330.05716.34
5.4.30.0370.04016.18
5.4.20.0400.05016.37
5.4.10.0500.05016.17
5.4.00.0330.03715.82
5.3.290.0330.04014.70
5.3.280.0370.04714.63
5.3.270.0400.04014.72
5.3.260.0430.04714.54
5.3.250.0470.06714.86
5.3.240.0670.02714.68
5.3.230.0430.07014.64
5.3.220.0330.04014.68
5.3.210.0430.04014.60
5.3.200.0330.03714.60
5.3.190.0400.04714.71
5.3.180.0370.03714.59
5.3.170.0400.03014.59
5.3.160.0430.03714.56
5.3.150.0300.04314.52
5.3.140.0370.03714.55
5.3.130.0370.03714.69
5.3.120.0470.02714.59
5.3.110.0270.04314.69
5.3.100.0330.03714.14
5.3.90.0400.03014.20
5.3.80.0470.03314.28
5.3.70.0370.04314.20
5.3.60.0370.04713.96
5.3.50.0400.03713.88
5.3.40.0330.03713.98
5.3.30.0330.03713.84
5.3.20.0370.03013.63
5.3.10.0430.02713.69
5.3.00.0370.03313.68
5.2.170.0200.03711.19
5.2.160.0270.04311.11
5.2.150.0230.03311.05
5.2.140.0270.03011.26
5.2.130.0330.02311.05
5.2.120.0330.02311.19
5.2.110.0300.03311.14
5.2.100.0270.03011.10
5.2.90.0330.02311.29
5.2.80.0270.03011.13
5.2.70.0330.03711.14
5.2.60.0300.03311.09
5.2.50.0300.02711.20
5.2.40.0230.02711.14
5.2.30.0170.03710.98
5.2.20.0270.03310.96
5.2.10.0230.03710.87
5.2.00.0300.02010.75
5.1.60.0270.02010.42
5.1.50.0200.02710.42
5.1.40.0230.02310.42
5.1.30.0270.02010.42
5.1.20.0270.02710.42
5.1.10.0200.03310.42
5.1.00.0270.02310.42
5.0.50.0130.02010.42
5.0.40.0100.02710.42
5.0.30.0100.03310.42
5.0.20.0100.02010.42
5.0.10.0070.02310.42
5.0.00.0130.03010.42
4.4.90.0100.01710.42
4.4.80.0170.01010.42
4.4.70.0100.02010.42
4.4.60.0100.01710.42
4.4.50.0100.02310.42
4.4.40.0100.02310.42
4.4.30.0100.01710.42
4.4.20.0130.01310.42
4.4.10.0100.02010.42
4.4.00.0100.02710.42
4.3.110.0130.01310.42
4.3.100.0100.01710.42
4.3.90.0130.01310.42
4.3.80.0100.02310.42
4.3.70.0100.01710.42
4.3.60.0130.01710.42
4.3.50.0130.01310.42
4.3.40.0100.02310.42
4.3.30.0070.02010.42
4.3.20.0000.02010.42
4.3.10.0130.02310.42
4.3.00.0070.02310.42

preferences:
43.43 ms | 401 KiB | 5 Q