Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7509667
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T22:59:07+00:00 2026-05-29T22:59:07+00:00

I have below array. Array ( [Image] => Array ( [0] => Array (

  • 0

I have below array.

 Array
 (

  [Image] => Array
    (
        [0] => Array
            (
                [thumbnail_url] => http://www.xyz.com/img/uploadsChatImage/42/thumbnails/chicken_1.png
            )

        [1] => Array
            (
                [name] => chicken_1.png
            )

        [2] => Array
            (
                [thumbnail_url] => http://www.xyz.com/img/uploadsChatImage/42/thumbnails/chicken_2.png
            )

        [3] => Array
            (
                [name] => chicken_2.png
            )

        [4] => Array
            (
                [thumbnail_url] => http://www.xyz.com/img/uploadsChatImage/42/thumbnails/chicken_3.png
            )

        [5] => Array
            (
                [name] => chicken_3.png
            )

    )

)

But I want to something like this

  Array
 (
  [Image] => Array
    (
        [0] => Array
            (
                [thumbnail_url] => http://www.xyz.com/img/uploadsChatImage/42/thumbnails/chicken_1.png
                 [name] => chicken_1.png
            )

        [1] => Array
            (
                [thumbnail_url] => http://www.xyz.com/img/uploadsChatImage/42/thumbnails/chicken_2.png
             [name] => chicken_2.png
            )

        [2] => Array
            (
                [thumbnail_url] => http://www.xyz.com/img/uploadsChatImage/42/thumbnails/chicken_3.png
             [name] => chicken_3.png
            )

    )

  )

What should I do for this?

Thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T22:59:08+00:00Added an answer on May 29, 2026 at 10:59 pm

    Like this, for example

      $arr = array('image'=>array(
        array('thumbnail_url'=>'url1'),
        array('name'=>'name1'),
        array('thumbnail_url'=>'url2'),
        array('name'=>'name2'),
        array('thumbnail_url'=>'url3'),
        array('name'=>'name3'),
        array('thumbnail_url'=>'url4'),
        array('name'=>'name4')
       )
      );
    
      $l = count($arr['image']);
      for($i=$l-2; $i>=0; $i-=2)
      {
          $arr['image'][$i] = array_merge($arr['image'][$i], $arr['image'][$i+1]);
          unset($arr['image'][$i+1]);
      }
      $arr['image'] = array_values($arr['image']);
      print_r($arr);
    

    or

      $ar = &$arr['image'];
      $l = count($ar);
      for($i=$l-2; $i>=0; $i-=2)
      {
          $ar[$i] = array_merge($ar[$i], $ar[$i+1]);
          unset($ar[$i+1]);
      }
      $ar = array_values($ar);
      print_r($arr);
    

    Result is

    Array
    (
        [image] => Array
            (
                [0] => Array
                    (
                        [thumbnail_url] => url1
                        [name] => name1
                    )
    
                [1] => Array
                    (
                        [thumbnail_url] => url2
                        [name] => name2
                    )
    
                [2] => Array
                    (
                        [thumbnail_url] => url3
                        [name] => name3
                    )
    
                [3] => Array
                    (
                        [thumbnail_url] => url4
                        [name] => name4
                    )
    
            )
    
    )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have an array below string stringArray = new stringArray[12]; stringArray[0] = 0,1; stringArray[1]
i have an array like below int[] array = new array[n];// n may be
I have an array of array like below with all numeric values. I want
I have a byte array highlighted below, how do I insert it into a
I have a C++ array declared as mentioned below: CString carray[] = { A,
I have an array of 1000 or so entries, with examples below: wickedweather liquidweather
I have the code below: $(document).ready(function() { var bgimages=new Array() bgImages[0]=bg.jpg bgImages[1]=bg2.jpg //sloppy preload
I have a basic image gallery with four thumbnails and four large images one
I have an array of urls. Each url contains one image. I need to
I have an array (below) var img_name = new Array(images/test.jpg, images/test.jpg); var imgTotal =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.