Advertisement
zornitza_gencheva

02_task_Forms_PHP

Aug 18th, 2014
295
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. echo "<form action='01_PrintTags.php' method='post'>" .
  2.         "<p>Enter tags: </p>" .
  3.         "<input type='text' name='text' />" .
  4.         "<input type='submit' value='submit' name='submit' /><br> .
  5.         </form>";
  6.  
  7. if(isset($_POST['text']))
  8. {
  9.  
  10.    $arrayInput = explode(", ",$_POST['text']);
  11.    $count = array_count_values($arrayInput);
  12.    $keys = array_keys($count);
  13.    $values = array_values($count);
  14.  
  15.     foreach($count as $key=>$item) {
  16.         echo $key. ' : ' . $item . ' times' . '<br>';
  17.     }
  18.  
  19.     for($i = 0; $i < count($keys) - 1; $i++) {
  20.          $temp = $values[0];
  21.          if($temp == $values[$i]) {
  22.               echo "Most frequent Tag is: $keys[$i]" . "<br>";
  23.          }
  24.          else {
  25.               break;
  26.          }
  27.  
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement