That works well if slus_123.45 was the only acceptable format.. but if the user enters any other format nothing is inserted.
I need the format of anything entered to change, basically..
So if slus-12345 is entered, it stays the same. If slus12345 is entered, it's changed to slus-12345... if slus_123.45 is entered, it changes to slus-12345..
I feel like this can be accomplished somehow with the simple code that I am already using.
Here is my current method to just replace everything with ""
Code:
if(isset($_POST['gamecode'])) {
$gamecode = ($_POST['gamecode']);
$cleangc = preg_replace("/[^a-zA-Z0-9\s]/", "", $gamecode);
$cleangc = strtoupper ($cleangc);
} else {
$gamecode = "None";
}
I'm looking for something that instead of replacing everything with "", instead it'd be like
Code:
$cleangc = preg_replace("/([^a-zA-Z]) ([0-9\s])/", "$1-$2", $gamecode);
Accept working xD
Any tip appreciated!