• 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

Required field only if another field has a value, must be empty otherwise

How to use a PHP MVC Controller, one thats invoked by calling a URL, to call and execute more than one function? [duplicate]

How to create custom authentication in laravel 8?

Merge key and value of array index [duplicate]

Reducing authentication calls on external API (Laravel 5.6)

Using PHP to connect to a remote MSSQL database

jQuery Ajax Post with data

Maatwebsite Excel 3.1 : how do I skip duplicate data when imported?

How to loop sql table data inside a html table

Normalize DateInterval in PHP

Show rotation of tweets using current day of month

XDebug not working in VScode for php debugging

Read users and passwords from a txt file

cakephp save drag and drop list order to database

How to get transaction details in notify_url page in paypal

About Contact Privacy policy Terms and conditions