PHP Convert multi-dimentional array into single array

Today, We want to share with you PHP Convert multi-dimentional array into single array.In this post we will show you How to restructure multi-dimensional array with columns as rows?, hear for How to convert multi-dimensional array into single array using php? we will give you demo and example for implement.In this post, we will learn about Restructure multidimensional array of column data into multidimensional array of row data with an example.

PHP Convert multi-dimentional array into single array

There are the Following The simple About Convert multidimensional array into single array Full Information With Example and source code.

As I will cover this Post with live Working example to develop convert multidimensional array to single array laravel, so the convert associative array to single dimensional array in php is used for this example is following below.

Restructure multi-dimentional array into single dimention

Simple PHP multi-dimentional array

Simple PHP – Restructure multi-dimentional array into single dimention

‘argument_1’ => ‘Welcome To the Sachin Namste’,
‘argument_2’ => ‘Welcome To the Virat Namste’,
‘param_2’ => ‘Welcome To the Ravi Namste’,
‘param_3’ => array(
‘argument_1’ => array(
‘foo_1’ => ‘Welcome To the Mayur Namste’,
‘argument_2’ => ‘Welcome To the Trump Namste’,
‘Welcome To the Modi Namste’,

Read Also:  Remove Last Comma string in javascript

We want the Like this output is

    [0] => Welcome To the Sachin Namste
    [1] => Welcome To the Virat Namste
    [2] => Welcome To the Ravi Namste
    [3] => Welcome To the Mayur Namste
    [4] => Welcome To the Trump Namste
    [5] => Welcome To the Modi Namste

PHP Source code

function restructure_array($obj) {
    if (!is_array($obj)) {
        return array($obj);

    $gretting_message = array();
    foreach ($obj as $k => $sub_obj) {
        $tmp = restructure_array($sub_obj);
        $gretting_message = array_merge($gretting_message, $tmp);
    return $gretting_message;

Web Programming Tutorials Example with Demo

Read :

Read Also:  Multiple Ternary Operator in php Examples


You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about how to convert 2d array to 1d array in php.
I would like to have feedback on my blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

About Pakainfo

I am Jaydeep Gondaliya, a software engineer, the founder and the person running Pakainfo. I'm a full-stack developer, entrepreneur and owner of I live in India and I love to write tutorials and tips that can help to other artisan, a Passionate Blogger, who love to share the informative content on PHP, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.

View all posts by Pakainfo →

Leave a Reply

Your email address will not be published. Required fields are marked *