[英]Php array_merge to one result
How to combine all the arrays into one total result?如何将所有数组合并为一个总结果? now the results with echo like 252 299 i need get total result 252+299 and get from echo 551
现在回声的结果像 252 299 我需要得到总结果 252+299 并从回声 551 中得到
<?php
$videoListt = array_merge($topchan1["items"],$topchan2["items"]);
for( $i= 0 ; $i <= count($videoListt)-1 ; $i++ )
{
echo $videoListt[$i]["statistics"]["subscriberCount"];
}
?>
You can increment a variable from within each iteration of your loop, then output it at the end:您可以在循环的每次迭代中增加一个变量,然后在最后输出它:
$subscriberCount = 0;
for ($i = 0; $i <= count($videoListt) - 1; $i++) {
$subscriberCount += $videoListt[$i]['statistics']['subscriberCount'];
}
echo $subscriberCount;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.