• 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

Yii2 redirecting to previous page after login

Execute only one time and then wait set period of time before executing again

VichUploaderBundle error "Expected argument of type "File", "NULL" given" when submitting the form without selecting any file

WooCommerce Additional Information - if empty, hide

Exception thrown during the rendering of a template("Parameter "id" for route "url" must match "[^/]++" ("" given) to generate a corresponding URL.")

Last order would be re-order in wooCommerce. How is it possible?

PHP Array split string and Integers

Laravel whole batch is cancelled if one Job fails

Laravel Model save() & update() Not Saving

PHP: How to solve ob_start() in combination imagepng() issue?

How to read laravel_session cookies saved in cookie memory of browser in client side?

PHP - Check if string contains words longer than 4 characters, then include "+ *", and for those shorter than 4 characters include only "*"

passwordless LDAP login and get user information using Kerberos ticket in PHP

get attribute from class not working php 7

java URL working on browser but not in client program

About Contact Privacy policy Terms and conditions