<form action="<?php htmlentities($_SERVER['PHP_SELF']);?>" method="get">
<input type="text" name="word" placeholder="enter text here">
<input type="submit" value="submit" name="submit">
</form>
<?php
if(isset($_GET['submit'])){
$word=$_GET['word'];
$word1=explode(' ',$word);
$result=array_combine($word1,array_fill(0,count($word1),0));
foreach($word1 as $words){
$result[$words]++;
}
foreach($result as $result1 => $count){
//echo "count"."$result1 "." .$count.";
echo"<table border='5px' width='10%'><tr><th>$result1</th><td>$count</td></tr>";
}
}
?>
No comments:
Post a Comment