0

我有一个 php mysql 查询结果如下...

Array
(
    [0] => stdClass Object
        (
            [id] => 52
            [sku] => 
            [name] => stone product 52
    )
    [1] => stdClass Object
        (
            [id] => 53
            [sku] => 
            [name] => stone product 53
    )

    .   
    .
    .   

)

Array
(
    [0] => stdClass Object
        (
            [id] => 12
            [sku] => 
            [name] => stone product 12
    )
    [1] => stdClass Object
        (
            [id] => 13
            [sku] => 
            [name] => stone product 13
    )

    .   
    .
    .   

)

我想要的结果如下

Array(
    [0] => stdClass Object
        (
            [id] => 52
            [sku] => 
            [name] => stone product 52
    )
      [1] => stdClass Object
        (
            [id] => 53
            [sku] => 
            [name] => stone product 53
    )
     [2] => stdClass Object
        (
            [id] => 12
            [sku] => 
            [name] => stone product 12
    )
     [3] => stdClass Object
        (
            [id] => 13
            [sku] => 
            [name] => stone product 13
    )

在单个数组中

请建议我php代码

4

2 回答 2

0

您不应该在 php.ini 中加入这些结果。使用一个查询来获取两组结果,这将减少您的数据库读取。

于 2013-07-10T21:13:36.747 回答
0

您可以使用 array_merge 函数: http: //php.net/manual/en/function.array-merge.php

如果您正在处理内部包含数组的数组,则可以将它们与 foreach 调用合并

$my_array=get_the_result_from_mysql();//Here how do you get the result.

$new_array=array();
foreach ($my_array as $row) {

$new_array=array_merge($new_array,$row);

}

var_dump($new_array);

我认为这对你有帮助。

于 2013-07-10T21:14:28.903 回答