<?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, '_') );
You have javascript disabled. You will not be able to edit any code.