Jump to content

Array


common

Recommended Posts

I think the best approach would be to use str_word_count

 

Then when you get the array of words, loop through them with foreach

 

<?php
$string = "This is a string of words in a string sting of the next string to be a string";
$words = str_word_count($string, 1);

foreach ($words as $word) {
   $countArray[$word]++;
}

print_r($countArray);
?>

Link to comment
https://forums.phpfreaks.com/topic/148857-array/#findComment-781665
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.