Jump to content

changing values of a multidimensional array?


zander1983

Recommended Posts

Hi

I have an array which looks like this when i do a print_r():

 

Array ( [0] => Array ( [path] => 1 [order] => 2 ) [1] => Array ( [path] => 2 [order] => 1 ) [2] => Array ( [path] => 3 [order] => 2 ) )

 

In this instance, I want to change the values of the order key. So I do something like this so that the last array has a path of 3 and an order of 1, and the others have orders of 2

 

foreach ($old_images as $old_image){

if($old_image['path']==3){

$old_image['order']="1";

}

else{

$old_image['order']="2";

}

}

 

When i step through, i see that the order is changed, but when i do a print_r(), i get the same result. So even though im resetting the order value of the inside arrays, the multidimensional array does not change....

any ideas?

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.