Closed typo3ua closed 3 years ago
The iterator.shift
viewhelper does not change the input data, it merely returns the value of the first element.
Shifts the first value off $subject (but does not change $subject itself as array_shift would).
If I'm correct, in your code the variable foo
should hold the value of the first array element, i.e. an empty string '', whereas the text output of the whole operation (none, an empty string again) is set in the variable too
. The variable array
is unchanged all the time.
You might want to have a look at iterator.slice
.
Hello, @tantegerda1
You might want to have a look at
iterator.slice
.
Thank you for reply... can you give me an example
{v:variable.set(name: 'arr', value: '{0: \'\', 1: \'Item 1\', 2: \'Item 2\'}')}
{v:iterator.slice(haystack: '{arr}', start: 1, length: 2) -> v:variable.set(name: 'foo')}
Thanks! I did it...
I have array
I need to delete
0 => ''
I added{array -> v:iterator.shift(as: 'foo') -> v:variable.set(name: 'too')}
...and I get the sameWhat is wrong?