• 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

How to identify whether webp image is static or animated?

Get WooCommerce product variation attribute terms in admin products general box

Combining a describing and one array with data

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

PHP web3 ERC20 token function call

GuzzleHttp Hangs When Using Localhost

No definition found for function in vendor vscode

Search for array row with specific column value and return another value from qualifying row

Laravel You requested 1 items, but there are only 0 items available

PHPExcel_IOFactory::createWriter causes wrong behaviour

Get all WooCommerce products within own plugin

Login if user is active using Laravel Breeze

Symfony process run throws exception - executing on command line works

Can't find vendor/autoload.php for Ratchet

jwt decode throws Invalid argument supplied for foreach() on php-jwt and codeignitor 4

About Contact Privacy policy Terms and conditions