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 7402575
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T04:46:35+00:00 2026-05-29T04:46:35+00:00

I have got a 2d array called $myarray, and when I using var_dump($myarray), it

  • 0

I have got a 2d array called $myarray, and when I using var_dump($myarray), it gives me the following:

  array(4) { [0]=> array(2) { [0]=> string(3) "EUR" [1]=> string(9) "43,543.23" } [1]=> array(2) { [0]=> string(3) "USD" [1]=> string(9) "13,432.34" } [2]=> array(2) { [0]=> string(3) "GBP" [1]=> string(8) "3,432.21" } [3]=> array(2) { [0]=> string(3) "CAD" [1]=> string(8) "2,321.34" } } 

But I want the output to be the follwing format:

Totals
GBP 3,432.21
USD 13,432.34
EUR 43,543.23
CAD 2,321.34

I assume that I need to sort the array to be:

GBP 3,432.21
USD 13,432.34
EUR 43,543.23
CAD 2,321.34

and add “Totals”, “” into the array, I might be wrong, soanybody could help me with that, any help will be greatly appreciated! I want it to be done in a programmatic way! how to sort the array $myarray to the expected output?

  • 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-29T04:46:35+00:00Added an answer on May 29, 2026 at 4:46 am

    Firstly, do not add anything non-data related to your array. You the string “Totals” should not be included in your array. If you just want the output, I suggest a better way to solve your problem :

    <?php 
       class MyMoney {
          var $type;
          var $value;
    
          public function __toString() {
             return $type."  ".$value."\n";    
          }
       }
    
       $output="Totals:\n";
       // $data is an array of MyMoney objects
       foreach( $entry in $data ) {
          $output.= (string) $entry;
       }
    
       dump($output);
    

    I hope this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got an array called $myarray with values like these: myarray = array (
Hello i got a question, i have a session array called 'addToCart', in there
i have have got an array of the complexe sort to store my navigation
In C, in an Unix environment (Plan9), I have got an array as memory.
I have a 1D array that got i*50 elements..i is a random number and
I got requirements- 1. Have random values in a List/Array and I need to
I've got a class with many string arrays. I'd like to have one generic
I've got problem using generics. I'm creating an interface called IProblem , where each
I have a Car class. It's got a property called enginePower. On the other
Reproducing the new array from existing array(multi array) If I have an array called

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.