Search
 
SCRIPT & CODE EXAMPLE
 

PHP

convert multdimentional array in array in php

$array = array(
    98 => array(
        'City' => 'Caracas',
        'Country' => 'Venezuela',
        'Continent' => 'Latin America',
    ),
    99 => array(
        'City' => 'Cairo',
        'Country' => 'Egypt',
        'Continent' => 'Middle East',
    ),
    105 => array(
        'City' => 'Abu Dhabi',
        'Country' => 'United Arab Emirates',
        'Continent' => 'Middle East',
    ),
    106 => array(
        'City' => 'Dubai',
        'Country' => 'United Arab Emirates',
        'Continent' => 'Middle East',
    ),
    107 => array(
        'City' => 'Montreal',
        'Country' => 'Canada',
        'Continent' => 'North America',
    )
);

$newArray = array();
foreach ($array as $row)
{
   $newArray[$row['Continent']][$row['Country']][] = $row['City'];
}

print_r($newArray);
Comment

PREVIOUS NEXT
Code Example
Php :: sql update row in php 
Php :: symlink.php laravel 
Php :: file_get_content 
Php :: php check image size before upload 
Php :: substract two datetime and get the different hours and minutes php 
Php :: array to string conversion php 
Php :: Composer detected issues 
Php :: php check if string is integer 
Php :: print in file php 
Php :: phpexcel set row height 
Php :: get cookie in laravel 
Php :: php radians to degrees 
Php :: dispatch job with queue name in laravel 
Php :: Creating Laravel and Vue Project 
Php :: laravel blade components 
Php :: Show all laravel valet folders 
Php :: symfony messenger 
Php :: html pagination php 
Php :: how simple get ip address json 
Php :: how check the checkbox is check php 
Php :: route() and with() in laravel 
Php :: laravel make factory 
Php :: create weekly calendar in php 
Php :: yii2 gridview action change urls 
Php :: php array serialize 
Php :: php interval day value 
Php :: php key_exists 
Php :: Hide Add to cart button on specific products 
Php :: php, Africa timezones 
Php :: not equal in laravel blade 
ADD CONTENT
Topic
Content
Source link
Name
8+6 =