Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <title>Most Frequent Tag</title>
- </head>
- <body>
- <p>Enter Tags:</p>
- <form action="02.%20MostFrequentTag.php" method="post">
- <input type="text" name="tags">
- <input type="submit" name="submit">
- </form>
- </body>
- </html>
- <?php
- if (isset($_POST['submit'])) {
- $allTags = preg_split('/[\s,]+/', $_POST['tags']);
- $countValues = array_count_values($allTags);
- arsort($countValues);
- $valueChecker = 0;
- $getMaxValueName = "";
- foreach ($countValues as $key => $keyValue) {
- echo("$key : $keyValue times <br>");
- if($keyValue > $valueChecker) {
- $valueChecker = $keyValue;
- $getMaxValueName = $key;
- }
- }
- echo("<p>Most Frequent Tag is: $getMaxValueName</p>");
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement