I have an array:
$myArray=array(
'hello my name is richard',
'hello my name is paul',
'hello my name is simon',
'hello it doesn\'t matter what my name is'
);
I need to find a substring (min. 2 words), which is repeated most often, maybe in an array format, so my returned array may look like this:
$return=array(
array('hello my', 3),
array('hello my name', 3),
array('hello my name is', 3),
array('my name', 4),
array('my name is', 4),
array('name is', 4),
);
Therefore, I can see from this array of arrays how often each row was repeated among all the rows in the array.
Is this the only way to do it this way? ..
function repeatedSubStrings($array){
foreach($array as $string){
$phrases=
foreach($phrases as $phrase){
}
}
}
I tried a solution similar to the one described above, but was too slow, processing around 1000 lines per second, can anyone do this faster?
source
share