alecthorne Posted February 3, 2013 Share Posted February 3, 2013 The Joomla ZOO extension places information within a multi-dimensional array named $elements. I display the array structure with: $arr = json_decode($elements,true);echo <pre>",print_r($arr,true),"</pre>"; The resulting array is below. Array ( [a3f9a1ba-85a2-4142-b0d6-6a85bef30cb5] => Array ( [0] => Array ( [value] => Telephone Number ) ) [e3145090-5017-44a9-bfaa-64602bacf96f] => Array ( [0] => Array ( [value] => Fax Number ) ) ) I need to be able to replace the value associated with a specific identifier ie. replace the ‘Telephone Number’ with another string $newdata, as this is associated with the identifier ‘a3f9a1ba-85a2-4142-b0d6-6a85bef30cb5’. I am new to this, but my initial attempt was as follows. $newdata = “ABCD”; foreach($elements as &$value) { $value['a3f9a1ba-85a2-4142-b0d6-6a85bef30cb5'] = $newdata; } This seems to have absolutely no effect. Can someone point me in the right direction. Thanks, Alec Quote Link to comment https://forums.phpfreaks.com/topic/273976-replacing-a-value-within-a-multi-dimensional-array/ Share on other sites More sharing options...
requinix Posted February 3, 2013 Share Posted February 3, 2013 $arr["a3f9a1ba-85a2-4142-b0d6-6a85bef30cb5"][0]["value"] = $newdata; Quote Link to comment https://forums.phpfreaks.com/topic/273976-replacing-a-value-within-a-multi-dimensional-array/#findComment-1409842 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.