Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Array in Array in Array in Array to one Array

Posted on 2003-11-12
1
Medium Priority
?
253 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 6

Accepted Solution

by:
DoppyNL earned 800 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
The viewer will learn how to count occurrences of each item in an array.
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…
Suggested Courses

604 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