Skip to content

Instantly share code, notes, and snippets.

<?php
$text = trim(fgets(STDIN));
$text = urldecode($text);
$word = trim(fgets(STDIN));
$word = urldecode($word);
$text = preg_replace('/[a-zA-Z\s],[.?!]/', '', $text);
$text = iconv('UTF-8', 'ISO-8859-1//IGNORE', $text);
$text = preg_split('/([.?!])/', $text, -1, PREG_SPLIT_DELIM_CAPTURE);
$sentences = array();
<?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'>";