I have this code here:
$imagePreFix = substr($fileinfo[\'basename\'], strpos($fileinfo[\'basename\'], \"_\") +1);
this gets me everything after
I think the easiest way to do this is to use explode.
$arr = explode('_', $fileinfo['basename']);
echo $arr[0];
This will split the string into an array of substrings. The length of the array depends on how many instances of _ there was. For example
"one_two_three"
Would be broken into an array
["one", "two", "three"]
Here's some documentation