Using arrays is still fairly new stuff for me.
I have an validation function that utilises an array of values to check against:
Code: Select all
$valid_dongle = true;
$dongle_array = array('410',
'411',
'413',
'414',
'415',
'416',
'417',
'418',
'420',
'444',
'1000',
'1001',
'1002',
'1096',
'1097',);
$dongle_number = substr($dongle, 0, 4);
if (!in_array($dongle_number, $dongle_array))
{
$valid_dongle = false;
}
return $valid_dongle;The problem I have is if I enter 4205469, obviously my code takes the first 4 digits and checks them against the array. The check would come back false even though the first three digits (420) are valid.
Now my first thought was to take the first three but then I could enter 10973265, this would not return true because 109 does not exist in the array but 1097 is a legitimate combination.
I hope this makes sense, could someone offer help please.
Regards
Jim