• Categories
    • PHP
    • phpMyAdmin
    • PHPMailer
    • FFMpeg
    • PHPEXcel
    • PHPDoc
    • PHPUnit
    • CakePHP
    • CakePHP 2.0
    • Cake PHP 2.1
    • CakePHP Model
    • Facebook PHP SDK
    • composer-php
    • PHP 7
    • PHP GD
    All Categories
  • About

How to loop a tree array with unknown depth and get array blocks?

phpmultidimensional-arraytree


PHP Snippet 1:

function saveAllValues($arr) {
    save_to_db($arr['id'], $arr['name'], $arr['is_master'], $arr['master_id']);
    if ($arr['has_children']) {
        array_map('saveAllValues, $arr['nodes']);
    }
}

Related Snippets

Warning: sqlite_query() expects parameter 1 to be resource, string given

User pool client {id}does not exist

javascript html popup window

What is PHP's equivalent of JavaScript's "array.every()"?

How to modify CSS in a specific page of the WP admin dashboard (backend)

Passing a boolean value from checkbox in Laravel form

Laravel database insert with combining array and string

PHP: set a (deep) array key from an array [closed]

Laravel Excel::store file empty after stored

PHP contact form configuration [duplicate]

Lumen - Postgresql setup - Composer

Can't find vendor/autoload.php for Ratchet

Codeigniter, Severity: error --> Exception: Too few arguments to function, admin dashboard shows HTTP error 500

How to find the date a user created their Google account

Star rating with half star support

About Contact Privacy policy Terms and conditions