I did a if thing to check if the variable only had aplha caracter but I also want to check if the variable strated with a vowel.
if (ctype_alpha($original)) {
print "oké";
}
else {
print "pas oké";
}
If there isn't any specific function, how could I know ? Thank you
$vocals = array('a','e','i','o','u');
if (ctype_alpha($original) && in_array($original{0}, $vocals)) {
print "oké";
} else {
print "pas oké";
}
With $string{index} you could access to a char into a certain position into $string.
With in_array you could check if that letter is contained into an array (in our example, vocals array)
If you wish, you could even use preg_match that will perform test with regular expressions
if (ctype_alpha($original) && preg_match('/^[aeiou]/i', $original))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With