Cindy Kline
Cindy Kline

Reputation: 11

API data into Array?

How to combine all the results into an array? An array that will look like that:

array(fan_page1, fan_page2,...)

$likes = $facebook->api("/me/likes?");
foreach($likes['data'] as $like2){
echo $like2["name"],"<br/>";            
}

Code above gives me only table, like:

fan_page1

fan_page2

Upvotes: 1

Views: 76

Answers (1)

Tewr
Tewr

Reputation: 3853

array_map can be used to transform elements of an array.

function map_data($value) {
    return $value['name'];
};

$likes = $facebook->api("/me/likes?");
$data = array_map("map_data", $likes['data']);

Upvotes: 1

Related Questions