3v4l.org

run code in 300+ PHP versions simultaneously
<?php $tests = [ "123_String" => "String", "233718_This_is_a_string" => "This_is_a_string", "83_Another Example" => "Another Example", ]; function viaExplode($string) { return explode('_', $string, 2)[1]; // the limit parameter gives reliability } function viaLtrim($string) { return ltrim($string, '0..9_'); // because character after first underscore is not a digit or underscore } function viaPregMatch($string) { return preg_match('/\d+_\K.+/', $string, $m) ? $m[0] : null; } function viaPregReplace($string) { return preg_replace('/^\d+_/', '', $string); } function viaSscanf($string) { return sscanf($string, '%*d_%[^\d]')[0]; // because no numbers in trailing substring } foreach ($tests as $test => $desired) { printf( "%s: %s, %s, %s, %s, %s\n", str_pad($test, 25, ' '), viaLtrim($test), viaPregMatch($test), viaPregReplace($test), viaExplode($test), viaSscanf($test) ); }
Output for git.master_jit, git.master
/bin/php-git-master: error while loading shared libraries: libonig.so.5: cannot open shared object file: No such file or directory
Process exited with code 127.
Output for rfc.property-hooks
123_String : String, String, String, String, String 233718_This_is_a_string : This_is_a_string, This_is_a_string, This_is_a_string, This_is_a_string, This_is_a_string 83_Another Example : Another Example, Another Example, Another Example, Another Example, Another Example

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
97.64 ms | 407 KiB | 5 Q