Jump to content

Replacing a Value within a Multi-Dimensional Array


alecthorne

Recommended Posts

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

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.