Home page >> Related Tutorials >>Body

PHP Tutorial - Converting 3D Arrays to 2D Arrays

Author: A little Jack    Time: 2022-09-09 13:40:05    Browse: 2364   

 PHP Tutorial - Converting 3D Arrays to 2D Arrays

This tutorial is about converting a 3D array into a 2D array. Let's take a look at the 3D array first:

 $result = array(     0 => array(         0 => array(             "name" => "dunqie",             "url" => "www.dunqie.com",         ),         1 => array(             "name" => "dunqie",             "url" => "www.dunqie.com",         )     ),     1 => Array(         0 => array(             "name" => "dunqie",             "url" => "www.dunqie.com",         ),     ) );

Use the following code for cycle reorganization:

 $newarr=array();    foreach($result as $value){     foreach($value as $v){         $newarr[]=$v;     } } print_r($newarr);

Output:

 PHP Tutorial - Converting 3D Arrays to 2D Arrays


Text label: PHP   3D array   2D array  
 A little Jack

A little Jack https://lkba.cn

The blogger focuses on Z-Blog website construction, website optimization, computer troubleshooting, reinstallation, optimization, maintenance system, etc., QQ/WX: 2126245521 (please specify the purpose)

Related articles

Previous:

Next:

No comment for this article - Welcome

 Please fill in the verification code

Processed : 0.049 SQL : 14