评论前请仔细阅读所有描述,我是新手。
以下是我的PHP代码
foreach ($mycatarr as $mycat)
{
$all_posts = all_posts_list($mycat);
}
现在的问题是all_posts_list($mycat)返回数组中的值。我想合并 foreach 循环生成的所有结果。
*请注意,这里我不想将这些结果存储在另一个数组中。
阵列结构
0 =>
array (size=9)
'pid' => string '3' (length=1)
'userid' => string '6' (length=1)
'url' => string 'http://buzzlink.local/terms-and-service' (length=39)
'title' => string 'This is just a test title of the content' (length=40)
'description' => string 'This is just a normal text description and I am enjoying it while typing in this kind of things as i
' (length=101)
'credits' => string '20' (length=2)
'categories' => string '10' (length=2)
'status' => string '1' (length=1)
'addtime' => string '1454391098' (length=10)
1 =>
array (size=9)
'pid' => string '16' (length=2)
'userid' => string '6' (length=1)
'url' => string 'http://buzzlink.local/terms-and-service' (length=39)
'title' => string 'This is just a test title of the content' (length=40)
'description' => string 'This is just a normal text description and I am enjoying it while typing in this kind of things as it helps me to speed up my typing and blah blah blah as this is just a test thing and description.' (length=197)
'credits' => string '20' (length=2)
'categories' => string '10' (length=2)
'status' => string '1' (length=1)
'addtime' => string '1454391098' (length=10)
使用这个:
$result=[];
foreach ($mycatarr as $mycat){
$result = array_merge($result, $mycat);
}
print_r($result);
使用 array_merge : http://us3.php.net/manual/de/function.array-merge.php
foreach ($mycatarr as $mycat)
{
$all_posts = array_merge($all_posts, all_posts_list($mycat));
}