Skip to content

Instantly share code, notes, and snippets.

@NinnaP
Last active February 16, 2017 12:56
Show Gist options
  • Save NinnaP/04b0d3f5c80d26ad7d094953c209bb58 to your computer and use it in GitHub Desktop.
Save NinnaP/04b0d3f5c80d26ad7d094953c209bb58 to your computer and use it in GitHub Desktop.
Word Mapping
<?php
$input = trim(fgets(STDIN));
$input = urldecode($input);
$input = iconv('UTF-8', 'ISO-8859-1//IGNORE', $input);
$input = strtolower($input);
$input =str_replace('input=', '', $input);
$input = array_count_values(str_word_count($input,1));
echo "<table border='2'>";
foreach ($input as $sample => $counter) {
echo "<tr>";
echo "<td>" . $sample . "</td>";
echo "<td>" . $counter . "</td>";
echo "</tr>";
}
echo "</table>";
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment