I am a newbie with shell scripts and I learnt a lot today. This is an extension to this question Assigning values printed by PHP CLI to shell variables
I got the solutio
With bash4, you can use mapfile to populate an array and process substitution to feed it:
mapfile -t array < <( your_command )
Then you can go through the array with:
for line in "${array[@]}"
Or use indices:
for i in "${#array[@]}" do : use "${array[i]}" done