Iv been looking for a way to search through an array of strings and find if there are any strings that contain a part of another string, if there is then i merge the whole array onto another array. EG:
Searching for jav:
array->[java] -> would return this value
and add that whole array to another
After looking around on stackoverflow and testing i found this solution using strpos which works...kind of:
$matches=array(); //just here to show the array is declared and is filled with items prior to calling
foreach($myarray as $fn){
if(strpos($fn,$searchString)){
$matches = array_merge($myarray,$matches);
}
}
The issue is, instead of adding the whole array its adding my search string each loop however, after double checking a number of times i dont understand why. Tts adding the original search item rather than the entire other array.... EG.
If i search for jav as shown above the array will merge to create an array of the correct length but with the value :
javjavjavjavjav
Any help in understanding exactly why this is or how to correct it would be appreciated.
$myarraycontain? example, is this just a simple flat array?$fnnot$myarray, just like below