I'm with Keith, having
$uri= as part of a print/echo in that for loop makes no sense. The $uri variable is not referenced within that loop.
You state this worked before you made some changes. Post the before code so someone here can zero in on what might be causing this.
The resultElements is an index name, try enclosing it in single quotes - $searchresults['resultElements']...
It would be interesting to see the results of this -
Could you post or attach a screen shot of this?