I have a PHP app that get's a play store app data and I want to check if the data I am getting is the version number.
A version number can be 0.0.1
to 99.99.99
or I may be wrong with the version number limitations.
How can I properly use regular expressions to handle this job?
This is how I currently do it:
$list = ["hello", "0.23.2", "world"];
foreach($list as $l) {
if (checkIfValidVersion($l)) {
echo "valid version!";
}
}
function checkIfValidVersion ($someString) {
$split = explode(".", $someString);
$isValid = false;
foreach($split as $s) {
$isValid = is_numeric($s) ? true : false;
}
return $isValid;
}