Solved

Array in Array in Array in Array to one Array

Posted on 2003-11-12
1
245 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Echo images using file system 2 31
can windows 10 wamp send mail()? 3 34
Hacked File Timestamps 4 49
Scope of $_SESSION 17 30
Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

920 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now