3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string = '15_some_text_or_numbers'; var_dump( sscanf($string, '%d')[0], (int) $string, preg_replace('/^\d+\K.*/', '', $string), preg_match('/^\d+/', $string, $m) ? $m[0] : null, strstr($string . '_', '_', true), // append an underscore to the input if not guaranteed explode('_', $string, 2)[0], // the limit parameter prevents needeless explosions strtok($string, '_') );

preferences:
30.68 ms | 411 KiB | 5 Q