Like this (where $mystring is the name of the variables you have assigned your string(s) to)
- Code: Select all
$mystring = substr($mystring, 0, strpos($mystring, "_"));
Just to explain:
strpos finds the position in the string of the first "_" so in your first example 600.1_GB_HPEG0600FBLSH that would be position 5.
substr then gets the part of the string based on the start position (0 - which is the very first character of the string) to the end position (5 - as returned by strpos).
So if we were to replace the code with the numbers it would look like this (as if you had put the numbers in manually)
- Code: Select all
$mystring = substr($mystring, 0, 5);