I keep getting duplicate entries (4 to be exact) when using stristr to filter a JSON by keywords. An example of my code is as follows:
$keywords = array('small','medium','large');
foreach($keywords as $keyword) {
foreach ($data as &posts) {
if(stristr($posts['message'],$keyword) !== FALSE ) {
print_r($posts);
}
}
}
When I do the following there are zero duplicates:
foreach ($data as &posts) {
print_r($posts);
}
I have tried array_uniq
but with no success. Can someone please point me in the right direction? Is there a better way to sort JSON?