-3

I have array of array and I just need to rearrange array according to me. Here is the output of my array.

Array
(
    [36736] => Array
        (
            [meta] => Array
                (
                    [Closing Date] => 
                    [Technical Consultant] => 
                    [Client Name] => 
                    [Stage] => Waiting for Technical Assignment
                    [Contract Name] =>
                    [Signing Rate] => 
                    [Contract Number] =>
                    [Client Number] => 
                    [Closer Name] =>
                    [Completed On] => 2019-05-23
                    [Assigned Date] => 05/22/2019 12:28 pm
            )
        )

Expected output

Array
(
    [36736] => Array
        (
            [meta] => Array
                (
                    [Client Name] => 
                    [Client Number] => 
                    [Contract Name] => this is secod contract or abc
                    [Contract Number] => 
                    [Stage] => Waiting for Technical Assignment
                    [Closing Date] => 
                    [Technical Consultant] =>                 
                    [Signing Rate] =>
                    [Closer Name] =>
                    [Completed On] => 2019-05-23
                    [Assigned Date] => 05/22/2019 12:28 pm
            )
        )
5
  • 2
    Rearrange it how? What kind of result are you looking for? Commented May 22, 2019 at 11:22
  • Where is your array where is your output? Commented May 22, 2019 at 11:38
  • @quickSwap here is my code, please check. Commented May 22, 2019 at 11:44
  • @tshimkusb plese check now. Commented May 22, 2019 at 11:45
  • Where is your code? I only see two array dumps without any further explanation of the difference between them Commented May 22, 2019 at 11:57

1 Answer 1

0

Demo link.

You can achieve by creating custom order key array you want,

$keys = ["Client Name", "Client Number", "Contract Name", "Contract Number", "Stage", "Closing Date",
    "Technical Consultant", "Signing Rate", "Closer Name", "Completed On", "Assigned Date"];
foreach ($arr as $key => &$value) { // & defines changes will be reflected at its address in memory
    $value['meta'] = array_replace(array_flip($keys), $value["meta"]);
}
Sign up to request clarification or add additional context in comments.

4 Comments

sir i have one more array look at here. Meta Stack Overflow => Array ( old array mention in question. ) [static] => Array ( [created_by] => 1 [created_time] => 1558508302 [modified_by] => [modified_time] => [record_status] => 3 )
i don't want to change static array.
@Akshay I made changes as per your requirement, once check my answer now.
its working for meta array. But i need my array back in same format. like:- meta()

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.