Write a program that stores vowels in an array When you program is given a character it should indicate whether the character is vowel or not?

1 answer

Answer

1031612

2026-07-30 21:00

+ Follow

That's easy to do!

This script will get the POST data from an HTML form and check if it is a vowel.

$vowels = array('a','e','i','o','u'); // Make variable "vowels" an array with all vowels in it

$_POST['string'] = $string;

if (strlen($string) != 1) { // String is not one character.

echo 'The "character" is not one character!";

} else if (in_array($string, $vowels)) { // Check if string is a vowel based on array

echo $string.' is a vowel!'; // Is a vowel

} else {

echo $string.' is not a vowel.'; // Is not a vowel

}

?>

NOTE: Sorry about horrible looking code, Wiki messed up my indenting.

ReportLike(0ShareFavorite

Copyright © 2026 eLLeNow.com All Rights Reserved.