Write a program which takes some input into an Array from console and finds the second last occurrence of a number from that array.
Problem Number : 3 Write a program which takes some input into an Array from console and finds the second last occurrence of a number from that array. (print the index) Sample Input: 10 15 2 35 11 9 7 2 47 13 2 2 Sample Output: 7 Source code : Download Solution for this problem : <?php //echo "Hello World !"; echo "<br/>"; $a=array(10,15,2,35,11,9,7,2,47,13,2); $count=0; for($i=count($a)-1;$i>0;$i--) { if($a[$i]==2) { $count++; } if($count==2){ break; } } echo $i; // echo $count; echo "<br/>"; echo "<br/>"; ?> Sample Input: 10 15 2 35 11 9 7 2 47 13 2 2 Sample Output: 7