Solved

Array in Array in Array in Array to one Array

Posted on 2003-11-12
1
247 Views
Last Modified: 2008-03-06
I had an array:

Array
(
 [0] => Array
           (
                [0] => Array
                          (
                                 [0] => a
                                 [1] => b
                                 [2] => c
                          )
                [1] => A
                [2] => B
                [3] => C
           )
)

And more sub array in main array

Now I would like to be:

Array
(
    [0] => a
    [1] => b
    [2] => c
    [3] => A
    [4] => B
    [5] => C
)

Please help me the way to make it in PHP!

Thank you very much indeed!
0
Comment
Question by:teekai
1 Comment
 
LVL 6

Accepted Solution

by:
DoppyNL earned 200 total points
ID: 9730922
this should do the trick:

function single_array($entry)
{
    if(!isset($result))
        $result = array();
    foreach ($entry as $item)
    {
        if (is_array($item))
             $result = array_merge($result, single_array($item));
        else
             $result[] = $item
    }
    return($result);
}
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

861 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question