"echo a multidimensional array in php" Answer’s

0

It looks like you're only trying to write one important value from each array. Try a recursive function like so:

function RecursiveWrite($array) {
    foreach ($array as $vals) {
        echo $vals['comment_content'] . "n";
        RecursiveWrite($vals['child']);
    }
}

You could also make it a little more dynamic and have the 'comment_content' and 'child' strings passed into the function as parameters (and continue passing them in the recursive call).

Wednesday, March 31, 2021
 
lewiguez
answered 10 Months ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :
 
Share