• 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

Put content of wordpress page inside div

"There is no active transaction" when refreshing database in Laravel 8.0 test

Form Validation and Submission to database

Filter WooCommerce related products by Polylang language

How to get rid of ampersand using WP Nonce URL and WP Redirect or PHP header

Symfony/Form add attribute based on the data

Laravel after login Two factor not working

Using PHP to connect to a remote MSSQL database

Object of class stdClass could not be converted to string error

Adding the custom page with add_menu_page function on Wordpress

Whats the point of running Laravel with the command 'php artisan serve'?

PHP usort() order in case of equality

Zig-zag scan an N x N array

PHP: Telegram Bot: Insert line break to text message

Creating Combinations of Elements

About Contact Privacy policy Terms and conditions