我有一個數組,看起來像這樣,除了有超過40多個環流式嵌套循環
Array
(
[0] => stdClass Object
(
[id] => 1
[name] => name
[cost] => 20
[firstname] =>
(
[0] => first 1
[1] => first 2
)
[lastname] =>
(
[0] => last 1
[1] => last 2
)
[username] =>
(
[0] => username 1
[1] => username 2
)
)
[0] => stdClass Object
(
[id] => 1
[name] => name
[cost] => 20
[firstname] =>
(
[0] => first 1
[1] => first 2
)
[lastname] =>
(
[0] => last 1
[1] => last 2
)
[username] =>
(
[0] => username 1
[1] => username 2
)
)
(
我做這樣的事情,以獲得非嵌套的數組:
foreach($data as $row){
echo $row->id
}
,但我會怎麼做得到嵌套數組?我想能夠將其顯示爲:
名姓
用戶名
爲什麼你有幾個對象的名字數組? – Michas 2012-02-23 22:01:14
我擁有的是產品,然後是評論,名稱是所有評論的人 – Jacinto 2012-02-23 23:33:35
您在每個對象中都有3個數組。每個數組都有相同的長度嗎? – Michas 2012-02-23 23:46:56