Detecting extended_entities for all tweets search in php

php

#1

I need to get all the images of the tweets in the search, however when using isset to determine if extended_entities exists it converts my array to a string. How could I effectively detect that extended_entities exists? . Here is my code:

foreach ($tweets  as $key => $tweet) {
			if (isset($tweet->extended_entities->media)) {				
				foreach ($tweet->extended_entities->media as $key => $media) {
					if ($media->type=="photo") {
						$image[]=array(
							"media_url"=>$media->media_url_https,
							"media_w"  =>$media->sizes->small->w,
							"media_h"  =>$media->sizes->small->h);
					}
				
				}
			}else{
				$image="no image";
			}
		}

#2

This is not really related to the Twitter API itself but sounds like a PHP problem, you might want to ask on Stackoverflow, if you get no answer here.