• 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

Google Gmail API - How to login programatically?

Insert multidimensional array to codeigniter cart

Using array_intersect on a multi-dimensional array

Merge column values from two arrays to form an indexed array of associative arrays

How can I make this nested location configuration use the correct path to call a php program?

Extract house numbers from address string

sqlsrv_num_rows() expects parameter 1 to be resource, boolean given

How to auto populate preferredCountries from intl-tel-input with db output

MySQL - Connection failed: No route to host

php curl_exec() Connection refused when retrieving a remote image

The sum of the user's points

How to fix this error : Ask your hosting provider to use PHP 7.2.5 or higher for both HTTP and CLI?

Sum array values of a column within each column of an array with 3 levels

Why getting "Build step 'Execute shell' marked build as failure" error while creating a backup tar for files

Laravel 4 Redirect::back() not going to previous page (refreshing current page)

About Contact Privacy policy Terms and conditions