I have a word list based on some inputted text. I'm looping through the string which is exploded using PHP at each space.

I have an array and each word is placed into that array as a new item. Easy.

Now what I have is some words in my array multiple times. So I'm checking using the in_array function.

If it is I want to increase the value by one (It won't always be 2 of course).

This is where I'm at.

    $titlewords = explode(" ", $row['Title']);
    foreach($titlewords as $singleword){

        if (in_array($singleword, $words)) {
           // Increase array item value by +1
        } else {
            array_push($words, $singleword); // Insert word as new array item with value of 1
        }      
    }
    Write a Reply...