PHP array_push不正确的功能,使用什么样的? [英] PHP array_push not the right function, what to use?

查看:94
本文介绍了PHP array_push不正确的功能,使用什么样的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

array_push($数组的getData())给我:

array_push($array, getData()) gives me:

Array
(
    [customer] => One
    [itemno] => Yellow Ribbon

)
Array
(
    [customer] => One
    [itemno] => Blue Band
)
Array
(
    [0] => Array
        (
            [customer] => Two
            [itemno] => Red Tape
        )
)

但我想要的是:

Array
(
    [customer] => One
    [itemno] => Yellow Ribbon

)
Array
(
    [customer] => One
    [itemno] => Blue Band
)
Array
(
    [customer] => Two
    [itemno] => Red Tape
)

那我该怎么使用?

What am I supposed to use?

推荐答案

假设你正在使用$阵列数字键,一个简单的array_merge($数组的getData())应该工作,因为getData()会明显地返回一个数字-indexed多维数组

Assuming you're using numeric keys in $array, a simple array_merge($array,getData()) should work, because getData() apparently returns a numeric-indexed multi-dimensional array.

这篇关于PHP array_push不正确的功能,使用什么样的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆