Jump to content

Object Checking - (get_file_contents)


EmperorJazzy

Recommended Posts

So I'm reading a JSON, and I'm using the command GET_FILE_CONTENTS, and I'm getting results. However, the JSON is incomplete to a point where in some instances the variables/objects within do not always contain a certain array.

 

Issue; I'm getting errors returned when that particular array does not exist. The code below is the line that's getting the error returned because the TAGS[0] doesn't exist in all instances.

 

Question; How do I check if the array exists within the GET_FILE_CONTENTS object?

 

See example;

If($dall->tags[0]->name==$catgrp)

 

Error:

Notice: Undefined offset: 0 in /var/www/vhosts/website/httpdocs/testjson/index.php on line 63

Notice: Trying to get property of non-object in /var/www/vhosts/website/httpdocs/testjson/index.php on line 63

Link to comment
https://forums.phpfreaks.com/topic/258890-object-checking-get_file_contents/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.