请在评论前仔细阅读所有说明,我是新手。
以下是我的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)
答案 0 :(得分:0)
使用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));
}
答案 1 :(得分:0)
使用此:
$result=[];
foreach ($mycatarr as $mycat){
$result = array_merge($result, $mycat);
}
print_r($result);