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.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.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.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:
12.79 ms | 406 KiB | 5 Q