0

我想一起计算所有数组,但不知道我的问题

$output = array(
    'facebook'=> isset($finfo[0]) ? $finfo[0]->total_count : NULL,
    'twitter'=> isset($tinfo->count) ? $tinfo->count : NULL,
    'delicious'=> isset($dinfo[0]) ? $dinfo[0]->total_posts : NULL,
    'pinterest'=> isset($pinfo->count) ? $pinfo->count : NULL,
    'googlePlus'=> isset($gplus[0]['result']) ? $gplus[0]['result']['metadata']['globalCounts']['count'] : NULL

);

function getSocialCount($output){
    return json_encode($output[facebook]) + json_encode($output[twitter]) + json_encode($output[pinterest]) + json_encode($output[googlePlus]);
}

<div>All: <?php echo getSocialCount(); ?></div>

我写错了语法吗?

4

2 回答 2

1

是的,您的函数需要一个参数,而您没有给它任何参数。

改变:

 <?php echo getSocialCount(); ?>

到:

 <?php echo getSocialCount($output); ?>
于 2013-02-04T15:26:40.697 回答
0

也许你应该将你的数组添加$output到你的函数中..

<?php echo getSocialCount($output); ?>

于 2013-02-04T15:26:55.633 回答