V
V
Vladimir2016-01-07 23:42:52
PHP
Vladimir, 2016-01-07 23:42:52

How to output a multidimensional php array?

Dumped a variable, how best to output an array? CMS Bitrix

Array
(

    [0] => Array
        (
            [ID] => 8
            [NAME] => Красивое оформление
            [DESCRIPTION] => 
            [ACTIVE] => Y
            [DATE_UPDATE] => 2016-01-07 03:16:42
            [OWNER_ID] => 1
            [PARENT_ID] => 0
            [SITE_ID] => 
            [KEYWORDS] => 
            [ITEMS_COUNT] => 
            [ML_TYPE] => 1
        )

    [1] => Array
        (
            [ID] => 5
            [NAME] => Фотографии сотрудников
            [DESCRIPTION] => 
            [ACTIVE] => Y
            [DATE_UPDATE] => 2016-01-07 01:57:13
            [OWNER_ID] => 1
            [PARENT_ID] => 0
            [SITE_ID] => 
            [KEYWORDS] => 
            [ITEMS_COUNT] => 
            [ML_TYPE] => 1
        )

)

Answer the question

In order to leave comments, you need to log in

4 answer(s)
X
xmoonlight, 2016-01-07
@vova_kondrashov

foreach

$iterator = new RecursiveIteratorIterator(new RecursiveArrayIterator($array));
foreach($iterator as $key => $value) {
    if ($key==='ID' || $key==='NAME') echo "$key => $value\n";
}

R
Roman Romanov, 2016-01-07
@Roman_Romanov

foreach($array as $key => $items){
 foreach($items as $k => $value){
 echo "$k : $value";
}
}

if I'm not mistaken, it's like this

W
Walt Disney, 2016-01-08
@ruFelix

you seem to want something

foreach($a as $v){
 echo $v['id'], ':', $v['name'], ' ';
}

N
no_one_safe, 2016-01-08
@no_one_safe

util::var_dump($var);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question