Change values in arrays

Author Message

paolo barbieri

Sunday 12 June 2005 5:07:44 pm

I'm trying to change the value of a specified element in an array with the value of another array.
This is the code:

{set myarray[0]=$otherarray[3]}

But it doesn't work!
What's wrong?
I've found a 'replace' function, but it seems still not implemented yet.

Note that my array is the result of a fetch (so, it's an array of objects).

Please....i'm going crazy with this... :-/

<i>"Vinum bibant homines, animalia cetera fontes..."</i>

Serg Tsay

Wednesday 15 June 2005 9:40:45 pm

I solve this problem, here solution:

1. Remove element that you want to change($index - element index):
{set myarray=$myarray|remove($index, 1)}
2. Insert new element at needed place:
{set myarray=$myarray|insert($index, $newvalue)}

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.