Appreciate your intention but to be honest.. it sucks. 1st thing, it has some kind of bug(this array didnt have value on index 0)
HTML Code:
if $result[0]="0" then return 0
if $result^ ERROR
and on the other hand...dont use ImageSearch for task like this, pure packet-sending would be more effective, bug-free, faster and in general better