itdeveloper99 Posted November 3, 2010 Share Posted November 3, 2010 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 Quote Link to comment https://forums.phpfreaks.com/topic/217659-how-can-i-update-my-array-values/ Share on other sites More sharing options...
mikosiko Posted November 3, 2010 Share Posted November 3, 2010 no clear what you want to do.... do you want to update your table or your array? post your relevant code Quote Link to comment https://forums.phpfreaks.com/topic/217659-how-can-i-update-my-array-values/#findComment-1129909 Share on other sites More sharing options...
itdeveloper99 Posted November 5, 2010 Author Share Posted November 5, 2010 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.... Quote Link to comment https://forums.phpfreaks.com/topic/217659-how-can-i-update-my-array-values/#findComment-1130607 Share on other sites More sharing options...
BlueSkyIS Posted November 5, 2010 Share Posted November 5, 2010 http://php.net/manual/en/language.types.array.php Quote Link to comment https://forums.phpfreaks.com/topic/217659-how-can-i-update-my-array-values/#findComment-1130687 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.