Reputation: 621
<?php
$textarea = $_POST['textarea'];
$text = array($textarea);
if (isset($_POST["submit_btn"])) {
$submit = $_POST['submit_btn'];
echo $textarea;
echo "<br />";
echo str_word_count($textarea);
$arr = explode(' ', $textarea);
$arr1 = array_count_values($arr);
echo " words <br />";
foreach ($arr1 as $k => $v) {
echo "$k -- $v <br />";
}
}
?>
But I am not allowed to use str_word_count and array_count_values...
Upvotes: 0
Views: 251
Reputation: 174614
Since this is homework, try this approach:
At the end, print your associative array.
Upvotes: 5