Please help me write a PHP code that does the following Show me screenshots with
ID: 3915098 • Letter: P
Question
Please help me write a PHP code that does the following
Show me screenshots with it working please.
Provide three widgets on this "Sifter.php" as follows
[1] First Text Area is the input text where users will copy and paste the text. Make text Area big.
[2] Below the "input" text area, add a button called "Sift".
[3] Hitting the "Sift" button will drop all vowels in the input and shows only the base consonants in the output box.
If the input contains one line, then the output contains one line. if the input contains multiple lines, then the output contains multiple lines.
Explanation / Answer
----------------------------------------------Sifter.php----------------------------------------
<html>
<head>
</head>
<body>
<!-- create a form -->
<form action="index1.php" method="POST">
<!-- create a text area for input -->
<textarea name="input" rows="4" cols="50">
</textarea>
<br>
<input type="submit" value="Sift" />
<br>
</form>
</body>
</html>
------------------------------------------------------index1.php----------------------------------------------
<?php
$x = $_POST['input'];
// store the string without vowels
$y = "";
// create an array of vowels
$vowel = array( 'a','e','i','o','u','A','E','I','O','U' );
// traverse through the string $x
for( $i = 0 ; $i < strlen($x) ; $i++ )
{
if( $x[$i] == " " )
$y .= "<br>";
// if the current character is vowel
else if( !in_array($x[$i], $vowel) )
{
$y .= $x[$i];
}
}
echo $y;
?>
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.