I'm trying, unsuccessfully to make a cut of a string from a character contained in it, first I need to find the _
in the string, after finding it I need to cut it to him and after him to the ponto
, if it does not find the character I need to cut the string to the point.
Here's what I've tried so far;
Finding the character in the string:
$ID = '3803_452.jpg'; $termo = '_'; $padrao = '/' . $termo . '/'; if (preg_match($padrao, $ID)) { echo 'Tag encontrada'; } else { echo 'Tag não encontrada'; }
If there is no _
I need to cut the string to the point by playing in a variable, thus:
$Id = 3803
If it was found the _
I need to cut the string to it and after it to the point throwing each one into a variable.
It would look something like this:
$Id = 3803;
$Seq = 452;