So I'm trying to make a program that counts how many vowels are there in the user's first name. I tried to make the code but its not 100% functional, can someone take a look and tell me where I went wrong?
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
Enter your First Name:<br><br>
<form action="test2.php" method="post">
Name: <input type="text" name="fname" />
<input type="submit" />
</form>
<?php
$vowels=array("a","e","i","o","u");
$length=strlen($_POST["fname"]);
$count = 0;
for ($i = 0; $i != $length; $i++)
{
if (array_search($_POST["fname"][$i], $vowels))
{
$count++;
}
}
echo 'There are (' . $count . ') vowels in the string (' . $_POST["fname"] . ').';
?>
</body>
</html>