Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="utf-8" />
- <title>{ Project Name }</title>
- </head>
- <body>
- <?php
- $text = "Banana Apple Orange Apple Grape Banana Grape Grape Grape Banana Apple Orange Apple Grape Banana Grape Grape Grape";
- $text = explode(" ", $text);
- print_r($text);
- echo "<hr>";
- $strUnique = [];
- $wordUnique = "";
- $flag = 0;
- for($i = 0; $i < count($text); $i++)
- {
- $flag = 0;
- $wordUnique = $text[$i];
- for($j = 0; $j < $i; $j++)
- {
- if($wordUnique == $text[$j])
- {
- $flag = 1;
- }
- }
- if($flag == 0)
- {
- array_push($strUnique, $text[$i]);
- }
- }
- print_r($strUnique);
- echo "<hr>";
- $strUniqueCount = [];
- $broqch = 0;
- for($j = 0; $j < count($strUnique); $j++){
- $b = 0;
- $wordUnique = $strUnique[$j];
- for($i = 0; $i < count($text); $i++){
- if($wordUnique==$text[$i]){
- $broqch++;
- }
- }
- $strUniqueCount[$wordUnique] = $broqch;
- }
- print_r($strUniqueCount);
- echo "<hr>";
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement