Jump to content

Recommended Posts

Hi all,

 

I'm trying to figure out how to update values I have in an array.  I'm a bit stuck and hope someone can advise.

 

I've read about all sorts of bits but I'm stuck, I dont really understand associative so thought I'd post an example of my code for someone to hopefully assist..

 

so, if I have a table $fees, which is filled from a select, for example..

select * from `cases_fees`.    "contains fields for id, type, amount and others

 

now I want to do is foreach through that table and update a field called `amount`. 

 

but I cant understand the foreach >= as key part.  what is a key and what isn't ?  (I know what the keys of the db table arem but that's not the same eh?)

 

I'm fine with normal foreach, but I cant update back to the array so I need to find out how to be able to set valus back into $fees[`amount`]

 

hope someone can point me in the right direction please...

 

Ted

 

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/217659-how-can-i-update-my-array-values/
Share on other sites

sorry, yep, I'm trying to update just the array so I can update the values contained for use later in the code.

 

I haven't got any useful source code as I'm not actually sure how to write it, the example I posted is a representation of what I'm after.  I just want to be able to update values in the array for later use in the code, but I cant figure how to write that

 

I guess something like $fees[1]['amount'] = 5.  but I cant understand about the $key >= $v type of approach....

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.