Guest User

Untitled

a guest
Jan 19th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. <?php
  2. $array = ['200', '15','69','122','50','201'];
  3. $max_1 = 0;
  4. $max_2 = 0;
  5. for($i=0; $i<count($array); $i++) {
  6. if($array[$i] > $max_1) {
  7. echo "\n";
  8. print_r('First : ' .$i);
  9. echo "\n";
  10. $max_2 = $max_1;
  11. $max_1 = $array[$i];
  12. } else if($array[$i] > $max_2) {
  13. echo "\n";
  14. print_r('Second : '. $i);
  15. echo "\n";
  16. $max_2 = $array[$i];
  17. }
  18. }
  19. echo "Max=".$max_1;
  20. echo "\n";
  21. echo "Second_max=".$max_2;
Add Comment
Please, Sign In to add comment