How to get list of Amazon EC2 instances matching some filters using AWS SDK for PHP 2?
Victor's answer is great, but it wasn't working for me because I was missing one line:
$reservations=$result->toArray();
The Amazon PHP SDK 2 returns Guzzle Model objects for many things (including this), and they need to be converted to arrays before foreach will work. More info here:
http://guzzlephp.org/api/class-Guzzle.Service.Resource.Model.html