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

  • Home
  • SEARCH
  • 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 4272958
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T07:38:54+00:00 2026-05-21T07:38:54+00:00

I Have an array Array ( [0] => Array ( [COMPANY NAME] => 1

  • 0

I Have an array

Array
(
    [0] => Array
        (
            [COMPANY NAME] => 1
            [LPO NUMBER] => PO1
            [LPO DATE] => 2011-04-13 10:08:37
            [LPO AMT] => 1000
            [PENDING AMT] => 1000
            [PRIORITY] => 1
            [AMOUNT] => 200
            [BENEFICIARY NAME] => Self
            [PAYMENT AS] => 1
            [VENDOR NAME] => 0
            [FINAL PAYMENT] => 
            [doc_id] => 2
            [Vendor Name] => Dept. of Economic Development.
            [Reference Number] => PR_XHA_210
            [Pay Cheque Number] => N/A
            [Paid] => 0
        )

    [1] => Array
        (
            [COMPANY NAME] => 1
            [LPO NUMBER] => PO1
            [LPO DATE] => 2011-04-13 10:08:37
            [LPO AMT] => 1000
            [PENDING AMT] => 800
            [PRIORITY] => 1
            [AMOUNT] => 800
            [BENEFICIARY NAME] => Self
            [PAYMENT AS] => 1
            [VENDOR NAME] => 0
            [FINAL PAYMENT] => 
            [doc_id] => 3
            [Vendor Name] => Dept. of Economic Development.
            [Reference Number] => PR_XHA_211
            [Pay Cheque Number] => N/A
            [Paid] => 0
        )

)

I need to arrange array in my required sequence of indexes which is like

[0] => Array
        (
            [Reference Number] => PR_XHA_210
            [Vendor Name] => Dept. of Economic Development.
            [BENEFICIARY NAME] => Self
            [LPO DATE] => 2011-04-13 10:08:37
            [LPO NUMBER] => PO1
            [LPO AMT] => 1000
            [Paid] => 0
            [AMOUNT] => 200
            [doc_id] => 2
            [doc_id] => 2
            [Pay Cheque Number] => N/A

        )

How It can be done?
Pls Help…

  • 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-21T07:38:54+00:00Added an answer on May 21, 2026 at 7:38 am

    Try this (untested):

    $keys = array(
        'Reference Number',
        'Vendor Name',
        ...
    );
    
    $reordered = array();
    foreach ($array as $item) {
        $new_item = array();
        foreach ($keys as $key) {
            $new_item[$key] = $item[$key];
        }
        $reordered[] = $new_item;
    }
    

    This will create a new array $reordered which holds all your rows, with the keys reordered according to the order defined in $keys.

    Alternatively you could reorder your array in-place using uksort and a callback function (again, untested).

    function sort_keys($a, $b) {
        static $keys = array(
            'Reference Number',
            'Vendor Name',
            ...
        );
    
        return array_search($a, $keys) - array_search($b, $keys);
    }
    
    foreach ($array as &$item) {
        uksort($item, 'sort_keys');
    }
    

    A third option is to leave your array alone but to edit your view code:

    $keys = array(
        'Reference Number',
        'Vendor Name',
        ...
    );
    
    foreach ($array as $item) {
        foreach ($keys as $key) {
            printf('<tr><th>%s</th><td>%s</td></tr>',
                htmlspecialchars($key),
                htmlspecialchars($item[$key]));
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have array of select tag. <select id='uniqueID' name=status> <option value=1>Present</option> <option value=2>Absent</option> </select>
I have an Employee model that has a Name and Company I want to
I have an array of objects, like this: var companies = [ { name
I have a mysql database with around 1.5 million company records(name, country and other
I have array like this: $path = array ( [0] => site\projects\terrace_and_balcony\mexico.jpg [1] =>
if i have array array[0] = jack; array[1] = jill; array[2] = lisa; array[2]
An array is defined of assumed elements like I have array like String[] strArray
Let's say I have array of bytes: byte[] arr = new byte[] { 0,
VISUAL C++ Question Hi, I have array of 3 elements and I want to
Have an array of chars like char members[255]. How can I empty it completely

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.