• 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

Don't show recurring price for WooCommerce subscriptions worth 0$

SQLSTATE[HY000]: General error: 1 table posts has no column named *

PHP: Convert any string to UTF-8 without knowing the original character set, or at least try

Fatal error: Array callback has to contain indices 0 and 1

Getting values for an enum?

Refresh specific HTML content that retrieves data from MySQL

How to get values inside <![CDATA[values]] > using php DOM?

Apply filter array/return terms

Laravel Pagination links() not working

GRPC installed successfully on ubuntu but php is looking for it in another folder

Laravel 8 factory state afterCreating

Laravel : How to Create Dropdown to Select FOREIGN KEY from Other Table?

How to get multiple values with same key from an array PHP

Render the content of default_filter.php in Joomla front-end

Symfony Mercure "Failed to send an update"

About Contact Privacy policy Terms and conditions