Path

7x / documentation / exponential / technical manual / 5.x / templates / the template language / variable usage / how to modify an array elem...


Caution: This documentation is for Exponential, from version 3.x to 6.x.
For 5.x documentation covering Platform see Exponential Platform Documentation, for difference between legacy and Platform see 5.x Architecture overview.

How to modify an array element??

Where is the missing part "Changing the contents of array elements"?
Making a 'set' on an array element destroy the whole array.
Why there is no cross-link between "/reference/template_operators/arrays/array" and /templates/the_template_language/variable_usage?
  • Re: How to modify an array element??

    Actualy, to have the equivalent to the traditional PHP $myArray[$i]++, I use the following:
    {set $counts = $counts|insert($i,inc($counts[$i]))|remove(inc($i))}
    Huge, isn't it?
    • Re: Re: How to modify an array element??

      I mean :
      $myArray[$i]++
      {set $myArray = $myArray|insert($i,inc($myArray[$i]))|remove(inc($i))}
      • Re: Re: Re: How to modify an array element??

        {$myArray = $myarray|inc()}

Anonymous User (19/11/2007 11:57 am)

Anonymous User (19/11/2007 11:57 am)


Comments

  • Re: How to modify an array element??

    Actualy, to have the equivalent to the traditional PHP $myArray[$i]++, I use the following:
    {set $counts = $counts|insert($i,inc($counts[$i]))|remove(inc($i))}
    Huge, isn't it?
    • Re: Re: How to modify an array element??

      I mean :
      $myArray[$i]++
      {set $myArray = $myArray|insert($i,inc($myArray[$i]))|remove(inc($i))}
      • Re: Re: Re: How to modify an array element??

        {$myArray = $myarray|inc()}