I'm trying to validate if the user has entered the correct order, otherwise my script won't work.
The correct order is jpg, jpeg, png, zip
but what the user might enter is jpg,jpeg,png,zip
, which is wrong.
How can I validate if the correct order is entered?
Example of what I'm trying to archieve (this will not work, it's pure for you to get an idea of what I'm trying to archieve, no it will not work and it's purely wrong and invalid code):
function randomizer_extensions_validate( $input ) {
if(order == 'jpg, jpeg, png') {
return $input;
} else {
echo 'you might want to correct that';
}
}
<?php
define('order', 'jpg, jpeg, png, zip');
function randomizer_extensions_validate($input) {
if (order === $input)
return $input;
return false;
}
var_dump(randomizer_extensions_validate('jpg,jpeg,png,zip')); // returns false
var_dump(randomizer_extensions_validate('jpg, jpeg, png, zip')); // returns string 'jpg, jpeg, png, zip'
?>
This will compare the strings, and return false if not a match.