How to iterate over array indices in zsh?

In bash we can iterate over index of an array like this

~$ for i in "${!test[@]}"; do echo $i; done

where test is an array, say,

~$ test=(a "b c d" e f)

so that the output looks like

b c d

However, when I do the same in zsh I get an error:

➜ ~ for i in "${!test[@]}"; do echo $i; done
zsh: event not found: test[@]

What is going on?

What is the proper way of iterating over indices in zsh?

Go to Source
Author: Gao Zheng

How can I display Only the first Array/Object?

By using WordPress REST Api




What I want?

I just want to display [{“id”:13},
Means, I want to limit it to only 1 array Using REST API. Any one have solution on this?

Go to Source
Author: Muhaza