【发布时间】:2019-10-24 16:23:27
【问题描述】:
我想生成带有已定义子数组名称的 PHP 表(不确定我是否使用了正确的术语)。 通常我得到: 大批 但想通过以下方式替换它: 标准类对象
使用附加代码,我可以生成“标准”数组,但是当我想将 Array 替换为 stdClass 对象时 我得到了结果:
>>> so with following code:
$testarray = array(
'stdClass Object'=>
array('title' => 'Hotele - Miejsce',
'display' => 'hot_miejsce',
'align' => 'l',
'width' => 450,
'order' => 10,
'format' =>'' ,),
array('title' => 'Aktualizacja',
'display' => 'hot_updated',
'align' => 'c',
'width' => 200,
'order' => 20,
'format' =>'' ,),
);
>>> I get following
[0] : Array
(
[stdClass Object] => Array
(
[title] => Hotele - Miejsce
[display] => hot_miejsce
[align] => l
[width] => 450
[order] => 10
[format] =>
)
[0] => Array
(
[title] => Aktualizacja
[display] => hot_updated
[align] => c
[width] => 200
[order] => 20
[format] =>
)
)
>>>>> but wanted to get
[0] : Array
(
[0] => stdClass Object
(
[title] => Hotele - Miejsce
[display] => hot_miejsce
[align] => l
[width] => 450
[order] => 10
[format] =>
)
[1] => stdClass Object
(
[title] => Aktualizacja
[display] => hot_updated
[align] => c
[width] => 200
[order] => 20
[format] =>
)
)
>>> so how to modify my original code to get expected result
【问题讨论】:
标签: php matrix multidimensional-array