• 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

Convert every two values of an associative array into key-value pairs

Auto increment id JSON

WAMP Virtual Host not working

Laravel Carbon throws error The format separator does not match

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

How to pass security cloudflare server with php curl

What is PHP's equivalent of JavaScript's "array.every()"?

How to convert a carbon into string, to take the date only?

Installing Composer - Internal Error

Group data in a multidimensional array based on two columns

sqlsrv_num_rows() expects parameter 1 to be resource, boolean given

How to assert parameter attribute sub-structures in PHPUnit mock call expectations

Confirm Leave on External Links in Wordpress

Hide specific products from unlogged users based in product category in WooCommerce

How to disable only_full_group_by option in Laravel

About Contact Privacy policy Terms and conditions