U
U
Uzair Izha2015-12-10 17:39:48
PHP
Uzair Izha, 2015-12-10 17:39:48

How to use php to remove the last letter in a word, if only it is a vowel?

How to do it in the best and fastest way, and not just brute force.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
Muhammad, 2015-12-10
@muhammad_97

$str = "hello";
$vowels = ['a', 'e', 'i', 'o', 'u', 'y'];

if (in_array(substr($str) - 1), $vowels) {
    echo 'Гласная';
} else {
    echo 'Согласная';
}

R
romy4, 2015-12-10
@romy4

And how, apart from sorting through the letters, can you understand that it is a consonant?

6
65536, 2015-12-10
@65536

!in_array('a', 'e', ​​'and', ...)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question