I am looking for a way to fix a certain piece of coding I have, it's probably simple to solve but I'm reall stuck. I haven't created this code myself
The code is triggered by a user entering his details, and the next piece of code filters out 2 parts of an URL based on the login of the user.
$regex = "/ranking.asp\?Group=(([A-Za-z]+) - ([0-9]+))/";
if (preg_match_all($regex, $str, $matches_out)) {
$data->groupLevel = $matches_out[2][0];
$data->groupNumber = $matches_out[3][0];
}
$matches_out[2][0] provides a letter
$matches_out[3][0] provides a number
When a user hits the top tier, the url is not ranking.php?group=A - 1 anymore (for example) but just ranking.php. This will obviously return an error, because it's looking for something else.
Now what I want to do is something like
if(code doesnt provide error){
execute the code;
}else{
$data->groupLevel = 'toptier';
$data->groupNumber = 1;
}
Or something similar which practically does the same. I hope someone can help me with this, it's very much appreciated! :)