• 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

Composer Script echo

Issue with laravel eloquent model property

I cannot create a auto generated date time in mysql workbench

Why does array_map() with null as callback create an "array of arrays"?

"properties should not be accessed directly" issue during WooCommerce 3.0 checkout

WooCommerce - unset "<product> removed notice…" on cart page

VB.NET WebRequest with PHP POST

Increase value by 1 on button click

Laravel PHP: multiple project run at the same time [closed]

php mysql + create a friend request system

Object of class stdClass could not be converted to string error

using random function but it's displaying duplicates

WooCommerce: Add/display Product or Variation custom field everywhere

SQL to convert multiple rows into a single row of variable length

Updating and Synchronizing Woocommerce Subscriptions to Custom Date

About Contact Privacy policy Terms and conditions