3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php ini_set( 'error_reporing', -1 ); ini_set( 'display_errors', 1 ); $result = array_slice( array(), 10, 10, true ); var_dump( $result ); exit; $found = null; $route = '/_ticket/'; foreach ( explode( '/', trim( $route, '/' ) ) as $part => $r ) { $uscore = strpos( $r, '_' ); $times = substr_count( $r, '_' ); if ( 1 != $times || 0 != $uscore ) { continue; } $found = $part; break; } if ( null !== $found ) { $parts = explode( '/', trim( $route, '/' ) ); $before = array_slice( $parts, 0, $found, true ); $after = array_slice( $parts, $found + 1, null, true ); $replacePart = ltrim( $parts[ $found ], '_' ); $before[] = $replacePart; $before[] = $replacePart; foreach ( $after as $part ) { $before[] = $part; } var_dump( $before ); var_dump( $after ); }
Output for 5.0.2 - 7.1.0
array(0) { }
Output for 4.3.0 - 5.0.1
Warning: Wrong parameter count for array_slice() in /in/cucDK on line 5 NULL