s=; echo $s[(i)z];
prints this
4
3
2
0
Why is the last line 0 and not 1? The documentation of (i) and (r) states that if the pattern isn't found in the string, the length of the string plus 1 is returned. I can't find anything that would explain the 0.
For arrays, (i) behaves as expected. The following script
a=(a a a); echo $a[(i)z];
a=(a a); echo $a[(i)z];
a=(a); echo $a[(i)z];
a=(); echo $a[(i)z];
prints this
4
3
2
1