I’ve been working on a keyword detection portion of my app and it all seems to be working great except for $msg I can only get it to read one result which is the very first message.
I’m trying to get it to read through the entire array.
If I do a var_dump the results are there, I’m just not sure how to read through the array.
try {
$me = $facebook->api('/me');
$fql = "SELECT message FROM status WHERE uid= me()";
$param = array(
'method' => 'fql.query',
'query' => $fql,
'callback' => ''
);
$fqlResult = $facebook->api($param);}
} catch (FacebookApiException $e) {
}
foreach($fqlResult as $row){
$abt = strtolower($row['about_me']);
$qts = strtolower($row['quotes']);
$msg = strtolower($row['message']);//This one is causing trouble!
$cursewrds = $abt . $msg . $qts . $status;
$keywords = array("test","curse","words);
$regex ="/(". implode('|', $keywords) .")/";
$total = (preg_match_all( $regex, $cursewrds, &$matches));
Heres what the array looks like when I do a fql query for $msg.
[
{
"message": "test 1"
},
{
"message": "test 2"
},
{
"message": "test 3"
},
{
"message": "test 4"
}
]
P.S. I’m not the best at php but if I’m here I’ve tried everything I can think of.
Not sure what you have going on there, but the problem seems to be your foreach loop is in the wrong place. Try: