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:
Text label: PHP 3D array 2D array
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)
Copyright © 2020-2023 Jack's works Reserved.
Powered By Z-Blog Sitemap | Shu ICP Bei No. 2023025269 - 1
Processed : 0.049 SQL : 14