SHARE
TWEET

02_task_Forms_PHP

zornitza_gencheva Aug 18th, 2014 217 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top