Pages: [1]   Go Down
Author Topic: Altering array keys  (Read 420 times)
vaillant
Newbie
*

Karma: +0/-0
Offline Offline

Posts: 1


« on: January 29, 2009, 05:20:44 AM »

Hi,

$catalog is a 2d array.

By doing this:

foreach($catalog as $key => $value)
               {
                  echo $key."=>".$catalog[$key]['desc']." ".$catalog[$key]['price']."
";
               }

I get this:

101=>AA batteries (pack of 2) 2.90
102=>AA batteries (pack of 4) 5.49
103=>Backpack (black) 69.99
104=>Money belt with 6 compartments 13.49
105=>Haversack (red) 199.99
106=>Swiss Army knife (6 blades) 24.00
107=>Duffel bag (steel gray) 28.50

Now when I do:

sort($catalog);
               foreach($catalog as $key => $value)
               {
                  echo $key."=>".$catalog[$key]['desc']." ".$catalog[$key]['price']."
";
               }
Report to moderator   Logged

PhPHelper
Full Member
Hero Member
****

Karma: +50/-0
Offline Offline

Posts: 179



WWW
« Reply #1 on: February 10, 2009, 06:43:00 AM »

is there a question in there somewhere? I don't follow.
Report to moderator   Logged


Pages: [1]   Go Up
Print
 
Jump to:  

Powered by SMF 1.1.10 | SMF © 2006-2009, Simple Machines LLC | Theme Kani By Fussilet

Page created in 0.038 seconds with 23 queries.