3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* - Obey PSR coding standards as much as possible (I choose to disobey Joomla's suggested standards when they defy PSR). Most importantly, read PSR-12. - `is_array() || is_object()` seems sensibly replaced with `is_iterable()`. Are you deliberately not returning anything in this condition branch? - Use Joomla's database querying methods for consistency and usability (since you are sharing your snippet with the world). Code: function getJCFields($srcId, $fieldId = null, $dbfields = null, $context = null) { $context = $context ?? 'com_content.article'; if (is_iterable($srcId) ) { JLoader::register('FieldsHelper', JPATH_ADMINISTRATOR . '/components/com_fields/helpers/fields.php'); $jfields = FieldsHelper::getFields($context, $srcId, true); } elseif (ctype_digit((string)$srcId)) { $db = JFactory::getDbo(); $query = $db->getQuery(true) ->select($dbfields ?? "id,label,value") ->from("#__fields f") ->innerJoin("#__fields_values fv ON f.id = fd.field_id") ->where("context = " . $db->qn($context)) ->where("fv.item_id = " . (int)$srcId); if ($fieldId) { $query->where("f.id = " . (int)$fieldId); } $db->setQuery($query); return fieldId ? $db->loadObject() : $db->loadObjectList(); } } Regarding your displaying of the data... - With your view implementation, the default glue for `implode()` is an empty string and this parameter can be omitted to achieve the same effect. So `implode('', $cell)` becomes `implode($cell)`. - But if you are imploding with no glue, then you might as well just directly concatenate to your output string to avoid adding temporary variables to the scope. - Call `getJCFields()` only once per loop iteration Code: $fieldTable = '<div class="tbl chart">'; $srcid = ['id' => 24, 'catid' => 5]; $fields = [2, 3, 4, 5, 6, 8]; foreach ($fields as $fid) { $jcField = getJCFields($srcid, $fid); if ($jcField) { $fieldTable .= sprintf( '<div class="tr"> <div class="cell lbl">%s</div> <div class="cell val">%s</div> </div>', $jcField->label, $jcField->value ); } } $fieldTable .= '</div>'; */

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.0150.00318.43
8.3.50.0140.00319.86
8.3.40.0140.00018.73
8.3.30.0090.00618.59
8.3.20.0080.00024.18
8.3.10.0070.00024.66
8.3.00.0040.00426.16
8.2.180.0110.00325.92
8.2.170.0070.01418.64
8.2.160.0070.00722.96
8.2.150.0040.00425.66
8.2.140.0080.00024.66
8.2.130.0070.00026.16
8.2.120.0050.00220.80
8.2.110.0000.00920.27
8.2.100.0090.00317.78
8.2.90.0000.00817.72
8.2.80.0040.00417.97
8.2.70.0000.01117.68
8.2.60.0040.00418.03
8.2.50.0030.00518.10
8.2.40.0040.00419.21
8.2.30.0040.00419.12
8.2.20.0040.00417.98
8.2.10.0000.00719.08
8.2.00.0040.00419.02
8.1.280.0130.00325.92
8.1.270.0050.00224.01
8.1.260.0030.00626.35
8.1.250.0070.00028.09
8.1.240.0030.00622.04
8.1.230.0060.00623.79
8.1.220.0050.00217.74
8.1.210.0000.00820.07
8.1.200.0060.00317.21
8.1.190.0040.00417.00
8.1.180.0080.00018.10
8.1.170.0050.00318.59
8.1.160.0080.00018.85
8.1.150.0000.00718.61
8.1.140.0040.00418.72
8.1.130.0030.00320.05
8.1.120.0050.00317.21
8.1.110.0040.00417.33
8.1.100.0050.00217.34
8.1.90.0070.00017.19
8.1.80.0000.00917.21
8.1.70.0030.00317.36
8.1.60.0030.00617.47
8.1.50.0040.00417.23
8.1.40.0040.00417.42
8.1.30.0030.00617.40
8.1.20.0040.00417.48
8.1.10.0000.00817.37
8.1.00.0040.00417.33
8.0.300.0080.00020.09
8.0.290.0070.00016.58
8.0.280.0040.00418.19
8.0.270.0000.00716.67
8.0.260.0000.00618.33
8.0.250.0030.00316.80
8.0.240.0000.00716.70
8.0.230.0050.00216.74
8.0.220.0030.00316.72
8.0.210.0000.00716.68
8.0.200.0030.00316.76
8.0.190.0060.00316.79
8.0.180.0030.00516.65
8.0.170.0030.00516.67
8.0.160.0060.00316.71
8.0.150.0030.00316.70
8.0.140.0120.00016.71
8.0.130.0000.00613.18
8.0.120.0040.00416.55
8.0.110.0070.00016.61
8.0.100.0040.00416.64
8.0.90.0040.00416.70
8.0.80.0070.00716.79
8.0.70.0020.00516.77
8.0.60.0050.00216.62
8.0.50.0040.00416.73
8.0.30.0120.00616.78
8.0.20.0140.00816.74
8.0.10.0080.00016.74
8.0.00.0230.00316.73
7.4.330.0020.00216.63
7.4.320.0040.00416.34
7.4.300.0000.00616.36
7.4.290.0030.00316.20
7.4.280.0070.00316.43
7.4.270.0030.00316.38
7.4.260.0000.00716.30
7.4.250.0040.00416.30
7.4.240.0040.00416.38
7.4.230.0070.00016.48
7.4.220.0030.00416.30
7.4.210.0060.01016.46
7.4.200.0030.00516.36
7.4.130.0090.00916.35
7.4.120.0110.00716.34
7.4.110.0100.00716.26
7.4.100.0140.00716.20
7.4.90.0160.00816.18
7.4.80.0060.01216.30
7.4.70.0030.02016.39
7.4.60.0090.01216.44
7.4.50.0090.01216.38
7.4.40.0070.01516.18
7.4.30.0090.00916.25
7.4.20.0130.00616.00
7.4.10.0080.01216.05
7.4.00.0070.01416.46
7.3.330.0070.00016.04
7.3.320.0000.00613.03
7.3.310.0040.00416.17
7.3.300.0000.00616.14
7.3.290.0070.00916.13
7.3.280.0120.00616.04
7.3.260.0180.00416.36
7.3.230.0040.01216.32
7.3.210.0060.01416.21
7.3.200.0110.01115.92
7.3.190.0060.01516.01
7.3.180.0120.00616.23
7.3.170.0170.00316.23
7.3.160.0180.00316.11
7.3.150.0120.00616.04
7.3.140.0110.01115.89
7.3.130.0140.00716.15
7.3.120.0080.00816.05
7.3.110.0130.00315.93
7.3.100.0100.01015.93
7.3.90.0180.00015.89
7.3.80.0070.01015.90
7.3.70.0100.00616.15
7.3.60.0110.00615.94
7.3.50.0140.00316.08
7.3.40.0100.00716.15
7.3.30.0090.00915.79
7.3.20.0100.00716.16
7.3.10.0130.00716.21
7.3.00.0100.00716.14
7.2.330.0120.00916.17
7.2.320.0120.00816.25
7.2.310.0100.00716.20
7.2.300.0070.01416.07
7.2.290.0090.00916.19
7.2.280.0070.01316.31
7.2.270.0160.00716.07
7.2.260.0070.01016.25
7.2.250.0120.00616.37
7.2.240.0110.00616.26
7.2.230.0080.01116.05
7.2.220.0090.01116.49
7.2.210.0150.00316.15
7.2.200.0130.00316.19
7.2.190.0060.01016.25
7.2.180.0030.01316.17
7.2.170.0060.01016.26
7.2.160.0090.00916.23
7.2.150.0120.00616.12
7.2.140.0100.01016.23
7.2.130.0090.01016.35
7.2.120.0100.01016.26
7.2.110.0090.00916.21
7.2.100.0120.00616.41
7.2.90.0060.01216.09
7.2.80.0030.01516.12
7.2.70.0100.00716.09
7.2.60.0030.01616.06
7.2.50.0070.01116.32
7.2.40.0160.00316.17
7.2.30.0120.00616.16
7.2.20.0140.00716.22
7.2.10.0040.01315.98
7.2.00.0100.00716.26

preferences:
57.64 ms | 401 KiB | 5 Q