• 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

XAMPP keeps showing Dashboard/Welcome Page instead of the Configuration Page

how can I set a session variable in Drupal 8 and get it in a php script?

mysql slow on updates for a well optimized query

What is my SQL missing?

How can I format this number correctly using PHP?

Reading input in php from terminal

Need to display only array value in JSON output

Elasticsearch - Want to sort by field in all indices where that particular field available or not if not then avoid it

I cannot create a auto generated date time in mysql workbench

How can I get data from PHP to Android TextView?

Using Associative arrays

Laravel Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) on a sub query with "ROW_NUMBER() OVER PARTITION"

Sort multidimensional array by column value within a column

What is the difference between client-side and server-side programming?

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

About Contact Privacy policy Terms and conditions