The code you posted does not do what you say it does. It prints 0, which is what's expected. Try showing some actual code that demonstrates what you're actually trying to do.
Yep...I found the problem...of course I was looking in the wrong spot...I thought the array was empty...but then I saw that my log was printing to STDOUT and not STDERR so I was missing the note that said I got 1 result hehe....
At least I was right in saying that I was slightly retarded with regards to this problem....