• 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

Upgrade PHP on AWS Linux

Form Validation and Submission to database

Update Total in checkout of Woocommerce with Ajax Request

Hi, I am making a contact form thingy, and my php isn't working any reason why?

Could not decode a text frame as UTF-8.

How to add a custom field to all Woocommerce attribute terms using add_action

How to run a shell as root from php (apache)

HTML and PHP in one file

insert multiple rows in a saveall in cakephp

PHP returning an error message and false

Add record for each array elements if missing in table

laravel automatically deletes server.php on php artisan serve

Use Python plotly chart in PHP

Cut an arabic string

How to programmatically find public properties of a class from inside one of it's methods

About Contact Privacy policy Terms and conditions