php get string before character 1

php get string before character

$data = "123_String";    
$whatIWant = substr($data, strpos($data, "_") + 1);    
echo $whatIWant;

Here is what the above code is Doing:
1. strpos() is used to find the position of the underscore in the string.
2. substr() is used to get the substring starting from the position of the underscore.

Similar Posts