3v4l.org

run code in 300+ PHP versions simultaneously
<?php function wp_create_links( $link_data ) { $links = array(); if ( isset( $link_data ) && is_array( $link_data ) ) { foreach ( $link_data as $key => $link ) { $attributes = array(); if ( isset( $link['attributes'] ) && is_array( $link['attributes'] ) ) { $attributes = $link['attributes']; } // URL check. if ( empty( $link['url'] ) || ! is_string( $link['url'] ) || '' === trim( $link['url'] ) ) { continue; } // Label check. if ( empty( $link['label'] ) || ! is_string( $link['label'] ) || '' === trim( $link['label'] ) ) { continue; } // Current check. if ( ! empty( $link['is_current'] ) && true === $link['is_current'] ) { $attributes['aria-current'] = 'page'; if ( empty( $attributes['class'] ) ) { $attributes['class'] = 'current'; } else { $attributes['class'] .= ' current'; } } // Collapse attributes to attribute="value" or boolean attributes. $attributes = array_map( function( $attribute, $value ) { // Mark invalid/empty attributes for removal. if ( empty( $attribute ) || ! is_string( $attribute ) ) { return false; } // Convert `int` and `float` values to `string`. if ( is_int( $value ) || is_float( $value ) ) { $value = (string) $value; } // Mark non-string values for removal. if ( ! is_string( $value ) ) { return false; } // On an empty `value`, assume this is a boolean attribute. if ( empty( $value ) ) { return $attribute; } return sprintf( '%s="%s"', $attribute, $value ); }, array_keys( $attributes ), array_values( $attributes ) ); // Clean up attributes. $attributes = array_filter( $attributes ); // Generate link. $links[ $key ] = sprintf( '<a href="%s"%s>%s</a>', $link['url'], ! empty( $attributes ) ? ' ' . implode( ' ', $attributes ) : '', $link['label'] ); } } return $links; } // Usage $links_data = array( 'my_link' => array( 'url' => 'https://example.org', 'label' => 'My Example Link', 'is_current' => true, 'attributes' => array( 'class' => 'menu-link', 'rel' => 'author me', ), ), 'my_other_link' => array( 'url' => 'https://example.com', 'label' => 'My Other Example Link', 'is_current' => true, 'attributes' => array( 'class' => 'menu-link', 'rel' => 'noreferer', ), ), ); $links = wp_create_links( $links_data ); // Want to wrap them? foreach ( $links as $id => $link ) { printf( '<li id="%s">%s</li>', $id, $link ); echo "\n"; }

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.01316.75
8.3.50.0150.00620.24
8.3.40.0140.00019.71
8.3.30.0060.00918.79
8.3.20.0080.00024.18
8.3.10.0040.00424.66
8.3.00.0030.00526.16
8.2.180.0100.00725.92
8.2.170.0080.00818.92
8.2.160.0060.00922.96
8.2.150.0000.00725.66
8.2.140.0050.00324.66
8.2.130.0080.00026.16
8.2.120.0040.00426.16
8.2.110.0070.00419.39
8.2.100.0080.00417.84
8.2.90.0050.00317.75
8.2.80.0060.00318.68
8.2.70.0050.00317.63
8.2.60.0040.00417.63
8.2.50.0000.00818.05
8.2.40.0040.00417.91
8.2.30.0000.00818.15
8.2.20.0040.00420.39
8.2.10.0060.00317.76
8.2.00.0000.00719.21
8.1.270.0060.00323.85
8.1.260.0040.00426.35
8.1.250.0050.00228.09
8.1.240.0050.00523.70
8.1.230.0040.00720.92
8.1.220.0000.00818.55
8.1.210.0030.00718.81
8.1.200.0030.00617.47
8.1.190.0030.00617.35
8.1.180.0040.00418.10
8.1.170.0000.00817.62
8.1.160.0020.00518.91
8.1.150.0040.00418.67
8.1.140.0040.00417.46
8.1.130.0000.00718.91
8.1.120.0040.00417.40
8.1.110.0080.00017.53
8.1.100.0070.00017.44
8.1.90.0070.00017.50
8.1.80.0070.00417.38
8.1.70.0000.00817.44
8.1.60.0080.00017.52
8.1.50.0040.00417.46
8.1.40.0070.00017.54
8.1.30.0050.00317.74
8.1.20.0050.00317.68
8.1.10.0000.00917.59
8.1.00.0000.00817.36
8.0.300.0000.00719.85
8.0.290.0000.00816.63
8.0.280.0000.00818.41
8.0.270.0030.00316.82
8.0.260.0000.00918.35
8.0.250.0000.00716.93
8.0.240.0000.00716.95
8.0.230.0000.00716.96
8.0.220.0000.00816.88
8.0.210.0040.00416.98
8.0.200.0050.00316.91
8.0.190.0050.00516.87
8.0.180.0040.00416.83
8.0.170.0080.00016.97
8.0.160.0090.00316.95
8.0.150.0070.00016.93
8.0.140.0070.00016.73
8.0.130.0000.00716.75
8.0.120.0000.00816.89
8.0.110.0060.00316.84
8.0.100.0050.00516.91
8.0.90.0000.00816.81
8.0.80.0000.00716.98
8.0.70.0050.00316.82
8.0.60.0070.00016.92
8.0.50.0050.00316.82
8.0.30.0040.00416.94
8.0.20.0040.00416.97
8.0.10.0040.00316.96
7.4.330.0000.00515.55
7.4.320.0030.00316.59
7.4.300.0000.00716.52
7.4.290.0070.00016.59
7.4.280.0100.00016.54
7.4.270.0040.00416.54
7.4.260.0080.00016.61
7.4.250.0030.00316.53
7.4.240.0040.00416.55
7.4.230.0030.00316.49
7.4.220.0070.00016.47
7.4.210.0080.00016.52
7.4.200.0070.00016.48
7.4.190.0000.00716.68
7.4.180.0030.00316.47
7.4.160.0030.00316.54
7.4.150.0030.00316.60
7.4.140.0030.00316.26
7.4.130.0000.00816.57
7.4.120.0050.00216.50
7.4.110.0030.00316.31
7.4.100.0040.00416.43
7.4.90.0050.00316.45
7.4.80.0060.00316.46
7.4.70.0040.00416.45
7.4.60.0040.00416.36
7.4.50.0070.00016.42
7.4.40.0000.00716.35
7.4.30.0000.00816.46
7.4.20.0000.00716.31
7.4.10.0080.00016.50
7.4.00.0070.00016.48

preferences:
50.05 ms | 400 KiB | 5 Q