Solved

Array in Array in Array in Array to one Array

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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

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 …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
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 …

707 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

12 Experts available now in Live!

Get 1:1 Help Now