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

  • Home
  • SEARCH
  • 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 7530169
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T04:50:13+00:00 2026-05-30T04:50:13+00:00

Hey guys I can’t seem to get the syntax here right, I’m just trying

  • 0

Hey guys I can’t seem to get the syntax here right, I’m just trying to see if type exists,
I’ve tried

if($obj->type)    /* do something */
if($obj[0]->type) /* do something */
if($obj->type[0]) /* do something */

On this

stdClass::__set_state(
array(
   '0' => 
  stdClass::__set_state(
  array(
     'report_number' => '555',
     'type' => 'citrus',
     'region' => 'Seattle',
     'customer_number' => '9757',
     'customer' => 'The Name',
     'location' => 'West Seattle, WA',
     'shipper' => 'Yamato Transport',
     'po' => '33215',
     'commodity' => 'RARE',
     'label' => 'PRODUCE',
  )),
))

But just can’t seem to get it right, I believe it has something to do with
[0] being an int instead of varchar but I have no idea….

  • 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-05-30T04:50:15+00:00Added an answer on May 30, 2026 at 4:50 am

    The output in your question is created by var_export which represents the data of the object as an array. But don’t get mislead by that, it’s in fact an object.

    Object properties are accessed by this syntax:

    $obj->property
    

    In your case the property is named 0 which is hard for PHP to deal with in plain code as it’s not a property name you could write right away like this:

    $obj->0
    

    Instead, you need to tell the PHP parser what the name is by enclosing it into {}:

    $obj->{0}
    

    You can then traverse further on to access the type property of 0:

    $obj->{0}->type
    

    Hope this is helpful, the question comes up from time to time, this is a related one with more related links: How do I access this object property?.

    The PHP Manual has this documented, but not very obvious on the Variable variables entry:

    In order to use variable variables with arrays, you have to resolve an ambiguity problem. That is, if you write $$a[1] then the parser needs to know if you meant to use $a[1] as a variable, or if you wanted $$a as the variable and then the [1] index from that variable. The syntax for resolving this ambiguity is: ${$a[1]} for the first case and ${$a}[1] for the second.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

hey guys, i can't seem to get it working. i have a div.post with
Hey Guys, I can't seem ti understand why these trivial named anchors here are
Hey Guys, here is my code for this, the only help i get from
hey guys, how can I just achieve this simple layout? I'm hoping the answer
Hey guys I have an older site that is coded in AS2(I can't get
Hey guys. I'm new to url rewrites but I can't seem to figure out
Hey guys i have edit text in my application User can type any of
Hey guys I'm trying to make a basic calculator (polish style) but can't figure
Hey guys i was just wondering how to do this in a input type
Hey guys, So I recently got a VPS, just so I can start gaining

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.