Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7798605
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T00:03:23+00:00 2026-06-02T00:03:23+00:00

I have an object called $definition in PHP. When I print_r($definition); I get Array

  • 0

I have an object called $definition in PHP.

When I

print_r($definition);

I get

Array ( [0] => Definition Object ( [extendedText] => [text] => Any of several carnivorous burrowing mammals of the family Mustelidae, such as Meles meles of Eurasia or Taxidea taxus of North America, having short legs, long claws on the front feet, and a heavy grizzled coat. [source] => [sourceDictionary] => ahd-legacy [citations] => Array ( ) [labels] => Array ( ) [score] => 0 [exampleUses] => Array ( ) [attributionUrl] => [seqString] => [attributionText] => from The American Heritage® Dictionary of the English Language, 4th Edition [relatedWords] => Array ( ) [sequence] => 0 [word] => badger [textProns] => Array ( ) [notes] => Array ( ) [partOfSpeech] => noun ) )

How do I print out the “text” and “partOfSpeech” components?

I’ve tried $definition->text, $definition[0][‘text’], $definition[‘text’]….

I’m lost…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T00:03:24+00:00Added an answer on June 2, 2026 at 12:03 am

    Try:

    echo $definition[0]->text;

    and

    echo $definition[0]->partOfSpeech;

    its created the object as the first index of the array 🙂

    Edit:
    With PHP, you can actually store multiple objects in an array. Which is cool, because instead of passing a ton of, for arguments sake, articles to a view, you can do something awesome like:

    <?php
    $articles = array();
    
    for($i = 0; $i < 10; $i ++)
    {
      $articles[$i] = new Article("Article $i", "Hello, this is $i");
    }
    
    ?>
    

    So in this example (and in yours) instead of setting the variable articles to an object, we have set the index of the array to an object.

    So if we wanted to pull out the 3rd article, we would do:

    <?php
      echo $articles[2]; // remember arrays start at 0 ;)
    ?>
    

    So with your vardump, we can see that its associated an index of 0 to that object.

    Annoying on why it did that.

    You could do this however to drop it:

    <?php
    $definition = array_pop( $definition[0] );
    
    echo $definition->text;
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an object called users that I use to store user objects that
I have an object called Contact. A Contact has a relationship with a set
Here is the scenario: I have an object called a Transaction that needs to
I have an object class called BOM. It has a method, getChildItem() which returns
I have an NSDate object called 'dueDate'. I'm trying to work out how to
I have a parent object called Page that has a List of objects called
I have a Django Queryset object called data containing string keys and float values.
I have a UITableView that displays various nsstrings from a custom object called a
I have an object with a property called name. This object has a sub
I have a data object -- a custom class called Notification -- that exposes

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.