Title: Undefined array key&#8230; eval()&#8217;d code on line&#8230;
Last modified: May 10, 2023

---

# Undefined array key… eval()’d code on line…

 *  Resolved [hereismine](https://wordpress.org/support/users/hereismine/)
 * (@hereismine)
 * [3 years ago](https://wordpress.org/support/topic/undefined-array-key-evald-code-on-line/)
 * Hello!
 * Can you help me? I got these error:
 * **Warning**: Undefined array key “content” in **/var/www/html/wp-content/plugins/
   code-snippets/php/front-end/class-frontend.php(210) : eval()’d code** on line**
   7**
 * **Warning**: Undefined array key “author” in **/var/www/html/wp-content/plugins/
   code-snippets/php/front-end/class-frontend.php(210) : eval()’d code** on line**
   9**
 * and here is the code:
 *     ```wp-block-code
       <?php
   
       $data = wpgetapi_endpoint( 'quotable', 'random', array('debug' => false) );
   
       echo $data['content'];
       echo '<br>';
       echo $data['author'];
   
       ?>
       ```
   
 * Thank you in advance!

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Author [Shea Bunge](https://wordpress.org/support/users/bungeshea/)
 * (@bungeshea)
 * [3 years ago](https://wordpress.org/support/topic/undefined-array-key-evald-code-on-line/#post-16727119)
 * Hi [@hereismine](https://wordpress.org/support/users/hereismine/),
 * You’re attempting to access array keys in the snippet which don’t exist. This
   can be fixed by providing a fallback value with the [`??` operator](https://www.php.net/manual/en/language.operators.comparison.php#language.operators.comparison.coalesce):
 *     ```wp-block-code
       <?php
   
       $data = wpgetapi_endpoint( 'quotable', 'random', array( 'debug' => false ) );
   
       echo $data['content'] ?? '';
       echo '<br>';
       echo $data['author'] ?? '';
       ```
   
 *  Thread Starter [hereismine](https://wordpress.org/support/users/hereismine/)
 * (@hereismine)
 * [3 years ago](https://wordpress.org/support/topic/undefined-array-key-evald-code-on-line/#post-16727161)
 * I have tried your code and the warning is gone but why no data appears?
 *  Plugin Author [Shea Bunge](https://wordpress.org/support/users/bungeshea/)
 * (@bungeshea)
 * [3 years ago](https://wordpress.org/support/topic/undefined-array-key-evald-code-on-line/#post-16743649)
 * That’s just down to what the `wpgetapi_endpoint` is returning. The array you’re
   receiving doesn’t contain any items called `content` or `author`, which is why
   the error messages were being displayed.
 * I’m not very familiar with where the `wpgetapi_endpoint` function comes from,
   so I’d recommend asking them how the function is supposed to work.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Undefined array key… eval()’d code on line…’ is closed to new replies.

 * ![](https://ps.w.org/code-snippets/assets/icon.svg?rev=2148878)
 * [Code Snippets](https://wordpress.org/plugins/code-snippets/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/code-snippets/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/code-snippets/)
 * [Active Topics](https://wordpress.org/support/plugin/code-snippets/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/code-snippets/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/code-snippets/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [Shea Bunge](https://wordpress.org/support/users/bungeshea/)
 * Last activity: [3 years ago](https://wordpress.org/support/topic/undefined-array-key-evald-code-on-line/#post-16743649)
 * Status: resolved