0% found this document useful (0 votes)
5 views6 pages

IT PHP Practical With OUTPUT

The document contains three separate PHP programs. The first program checks if a person is eligible to vote based on their age input, the second counts the number of vowels in a user-provided string, and the third performs operations on an associative array displaying scores and modifying the array. Each program includes HTML forms for user input and PHP logic for processing the data.

Uploaded by

avhadk46
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views6 pages

IT PHP Practical With OUTPUT

The document contains three separate PHP programs. The first program checks if a person is eligible to vote based on their age input, the second counts the number of vowels in a user-provided string, and the third performs operations on an associative array displaying scores and modifying the array. Each program includes HTML forms for user input and PHP logic for processing the data.

Uploaded by

avhadk46
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

SOP 1. Write a PHP program to check if a person is eligible to vote or not.

<html>

<head>

<title>Eligibility to Vote</title>

</head>

<body>

<h2>Check Eligibility to Vote</h2>

<form method="POST">

Enter Your Age: <input type="number" name="age" required>

<input type="submit" name="submit" value="Check">

</form>

<?php if(isset($_POST['submit'])){

$age = $_POST['age']; if($age >= 18){

echo "<p>Congratulations! You are eligible to vote.</p>";

else

echo "<p>Sorry, you are not eligible to vote.</p>";

?>

</body>

</html>
SOP 2. Write a PHP function to count the total number of vowels ( a, e, I, o, u) from the string. Accept a string by
using HTML form.

<html>

<body>

<h2>Find Number of Vowels in a String</h2>

<form action="" method="post">

<input type="text" name="string" >

<input type="submit" >

</form>

</body>

</html>

<?php if($_POST)

$string = strtolower($_POST['string']);

$vowels = array('a','e','i','o','u');

$len = strlen($string);

$num = 0;

for($i=0; $i<$len; $i++){ if(in_array($string[$i], $vowels))

$num++;

echo "Number of vowels : ".$num;

?>
SOP 3. Write a PHP program to perform the following operation on an associative array.

<?php
$ml=array("English"=>"55","Hindi"=>"60","Maths"=>"70","Marathi"=>"85");
echo "<br><br><b>Elements of an array along with their keys:</b>";
echo "<br> <br> Your score ".$ml['English']." in English";
echo "<br> <br> Your score ".$ml['Hindi']." in Hindi";
echo "<br> <br> Your score ".$ml['Maths']." in Maths";
echo "<br> <br> Your score ".$ml['Marathi']." in Marathi";
echo "<br><br><b>Size of an array is :</b>".count($ml);array_splice($ml,0,1);
echo "<br><br><b>
After deleting array is :</b>";
foreach($ml as $x => $x_value)
{echo "<br><br>Key=". $x. ", Value=" . $x_value;
echo "<br>";
}
?>

You might also like