• 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

Applying programmatically a coupon to an Order in WooCommerce3

how to make my own auto increment in php?

Add New Parameter to Existing URL using htaccess

Return multiple values from a function using mysqli_fetch_assoc [closed]

Laravel Livewire: jQuery not working in child component loaded via @if statement

Popup Window and PHP form

Can we define variables in `.tpl` files?

Open a popup box after receiving result from ajax

Is it possible to re-use an array taken from PHP via JSON in a $.ajax function?

Increase value by 1 on button click

Call to a member function givePermissionTo() on null

Inserting data into SQL Server Db An Invalid direction was specified

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

How to display MySQL table using php and edit it in a web browser

How to use React Router with Laravel?

About Contact Privacy policy Terms and conditions