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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.