PHP数组中的数组到Foreach和字符串[数组中的多个]

时间:2018-11-06 20:37:47

标签: php arrays string loops foreach

我试图这样做,但是我的PHP知识很少。希望您能提供帮助。我想做的foreach循环;

w.full()[0]
# array([[0., 1., 1., 0.],
#        [1., 0., 0., 1.],
#        [1., 0., 0., 1.],
#        [0., 1., 1., 0.]])

我想做的例子是foreach循环

Array
(
    [istasyonBilgileriList] => Array
    (
        [0] => Array
        (
            [istasyonId] => 234515950
            [istasyonKodu] => 1401
            [istasyonAdi] => Ankara
            [enlem] => 0.000000000000
            [boylam] => 0.000000000000
            [tarih] => Jul 25, 2017 10:00:00 AM
        )

        [1] => Array
        (
            [istasyonId] => 234515951
            [istasyonKodu] => 1402
            [istasyonAdi] => Enveriye
            [enlem] => 0.000000000000
            [boylam] => 0.000000000000
            [tarih] => Jul 25, 2017 10:00:00 AM
        )
        ...
        ...
        ...
    )
)

1 个答案:

答案 0 :(得分:0)

这是一个类似的示例,要输出内部foo值,我们可以遍历 boz 键:

<?php

$data =
[
    'boz' => 
    [
        [
            'foo' => 'Food'
        ],
        [
            'foo' => 'Fool'
        ]
    ]
];

foreach($data['boz'] as $item) {
    echo $item['foo'] . "\n";
}

输出:

Food
Fool