• 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

Can we define variables in `.tpl` files?

jQuery Ajax Post with data

Appending data to an anchor tag

I want to display a sweetalert after the inserting of data in my database

"Notice: Undefined variable", "Notice: Undefined index", "Warning: Undefined array key", and "Notice: Undefined offset" using PHP

Create a new line whenever an array value reaches more than 10 characters

Query Optimization, changing the queries in the loop into a single processing query

is there any way to validate a field that sometime is File(image) && sometime is String(Src of same image)

Laravel Blade checkbox not checked

php curl_exec() Connection refused when retrieving a remote image

Laravel Gates using model and returns "Using $this when not in object context" Line 28 of AzureUser model

error:14094410:SSL routines:ssl3_read_bytes:sslv3 alert handshake failure

Laravel Schedule not sending email

Trying to iterate over a mongodb cursor twice - failing

Statement that checks whether a URL contains a particular path?

About Contact Privacy policy Terms and conditions