• 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

Laravel unique validation on multiple columns

Laravel Command Schedule Not Working Properly

Handling expired token in Laravel

httpd.conf on Windows: can't locate API model structure `php8_module`

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

Check if string contains a value in array [duplicate]

PHP function Not Working As Expected From functions.php Include File

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

Call to a member function givePermissionTo() on null

How to unlink image from folder?

Converting alphabet letter to alphabet position in PHP [duplicate]

Post Form Data To phpmyadmin Database

Log file is not being written in Laravel 5.5

How to properly set "0000-00-00 00:00:00" as a DateTime in PHP

Select option from dropdown menu with PHP and mySql

About Contact Privacy policy Terms and conditions