Thursday 4 March 2021

Write a program that reads 10 element in array enter a number and find how many times the number is repeated in the list in PHP

Write a program that reads 10 element in array enter a number and find how many times the number is repeated in the list In PHP


Example:


<title>PHP:Write a program that reads 10 element in array enter a number and find how many times the number is repeated in the list </title>


<?php

/* Write a program that reads 10 element in array enter a number and find how many times the number is repeated in the list.*/

$n=array(1,2,9,4,5,9,7,8,9,10,9);

$sv=9;

$count=0;

for($a=1;$a<=10;$a++)

{

if($n[$a]==$sv)

{

$count++;

}

}

print"Searching values is found times = ".$count."<br>";

?>


</body>

</html>

OUTPUT:

Searching values is found times = 4

No comments:

Post a Comment