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.

eZ debug

Timing: Jan 31 2025 04:26:27
Script start
Timing: Jan 31 2025 04:26:27
Module start 'layout'
Timing: Jan 31 2025 04:26:27
Module start 'content'
Timing: Jan 31 2025 04:26:27
Module end 'content'
Timing: Jan 31 2025 04:26:27
Script end

Main resources:

Total runtime0.0149 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0044 588.1250151.2109
Module start 'layout' 0.00440.0022 739.335936.6484
Module start 'content' 0.00660.0066 775.984490.2500
Module end 'content' 0.01320.0016 866.234429.9922
Script end 0.0148  896.2266 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002215.0657140.0002
Check MTime0.00117.0724140.0001
Mysql Total
Database connection0.00064.234110.0006
Mysqli_queries0.002114.401530.0007
Looping result0.00000.073810.0000
Template Total0.00128.210.0012
Template load0.00085.524110.0008
Template processing0.00042.597610.0004
Override
Cache load0.00053.640510.0005
General
dbfile0.002818.816980.0003
String conversion0.00000.054640.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs