Hi ,

I have return type object is "$answer" and I am getting the output by ussing "echo $answer"; is :

array
  'AnswerId' => int 1
  'Comment' => string 'The license is found.OK'

  'LicenseInt' => 
         array
         'LicenseID' => string 'L005673’.                                                                                                             'Prod_ID' => int 5644
      'LicenseDate' => 
        object(DateTime)[35]
          public 'date' => string '2020-12-12 00:00:00' 
      'LicensesIssued' => int 0
      'VendorStr' => string '



  Now I am able to display the value by 

echo $answer->AnswerId;

but unable to display the value 'LicenseID' in array 'LicenseInt' or 'date' in array 'LicenseDate'.

If the snippet you've posted is for the $answer variable, then it looks to actually be an array, not an object. Do you have the actual var_dump output?

Based on the above:

echo $answer['AnswerId'];
echo $answer['LicenseInt']['licenseID'];
echo $answer['LicenseInt']['Prod_ID'];
echo $answer['LicenseInt']['LicenseDate']->date;

Hi ,

The displayed output using

var_dump(AnswerId);

and from your code giving the error :Fatal error: Cannot use object of type .

Please post the output from var_dump($answer) or whatever your variable is called.

Hi ,
done this issue.
Solution is :

echo $answer->LicenseInt['LicensesSold']; 

if the property "AnswerID" is your array, you can access is like this:

$answer->AnswerId["LicenseInt"]["LicenseID"]

Hi ,
see wich is done and which is not done marked on the right side.

object($answer)
  public 'AnswerId' => int 1                                //done 
  public 'Comment' => string 'The license is found.OK' ()   //done
  public 'LicenseInt' => 
    array
      'LicenseID' => string 'lkjljljljlkjlljljlkjlkjlj'      //done                                                                         ' (length=100)
      'Prod_ID' => int 5652                                 //done
      'LicensesSold' => int 0                               //done
      'Days' => int 0                                       //done
      'LicExpirDate' => 
        object(DateTime)[34]
          public 'date' => string '2001-01-01 00:00:00'     //not done
          public 'timezone_type' => int 3                    //not done
          public 'timezone' => string 'RPC'                 //not done           

respective syntax and output given here

echo $answer->AnswerId;   //working 
echo $answer->Comment;   //working
echo $answer->LicenceInt['LicenceID']; //working
echo $answer->LicenceInt['LicenceSold'];  //working

but 
echo $answer->LicenceInt->LicExpirDate['timezone_type'];   //not working 

because which is working is array in object but which is object in object is not working

The problem is that you're accessing LicenceInt as an object when previously you've accessed it as an array.

$answer->LicenceInt['LicExpirDate']->timezone_type;

didn't display any error but there is no output

   in this 
   $answer->LicenceInt['LicExpirDate']->timezone_type;
   already I tried it out

Did you echo the response? Have you tried to var_dump the response?

Yes I tried echo and tried var_dump but no output as yet

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.