Jump to content

how can I update my array values?


itdeveloper99

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....

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.