$curl = curl_init();
curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://livehealth.solutions/getAllTestsAndProfiles/?token=3f115cd0-c79b-11eb-b07b-0aa43715764a',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'GET',
));
$response = curl_exec($curl);
curl_close($curl);
$resArr = json_decode($response);
echo "<pre>"; print_r($resArr); echo "</pre>";

displays the list of array values... as shown below...
but i need to get specific object like test code /test id /test Name

Please help me out...

stdClass Object
(
[profileTestList] => Array
(
[0] => stdClass Object
(
[testAmount] => 2200.0
[testCode] => SPUTUM  CBNAAT
[testCategory] => -
[testList] => Array
(
[0] => stdClass Object

[1] => stdClass Object
(
[testAmount] => 0.0
[testCode] => @$*
[testCategory] => -
[departmentName] => Pathology
[testName] => 2nd Day
[testID] => 4565681
[integrationCode] => 
)

[2] => stdClass Object
(
[testAmount] => 0.0
[testCode] => @$*
[testCategory] => -
[departmentName] => Pathology
[testName] => 3rd Day
[testID] => 4565682
[integrationCode] => 
)

)

[testName] => SPUTUM  CBNAAT
[testID] => 4566044
[integrationCode] => 
)

[1] => stdClass Object
(
[testAmount] => 1499.0
[testCode] => Covid Master Health
[testCategory] => -
[testList] => Array
(
[0] => stdClass Object
(
[testAmount] => 300
[testCode] => CBP
[testCategory] => Haematology
[departmentName] => Lab
[testName] => CBP( complete blood picture)
[testID] => 4565933
[integrationCode] => 
)

[1] => stdClass Object
(
[testAmount] => 400.0
[testCode] => LIPID PROFILE
[testCategory] => Biochemistry
[departmentName] => Lab
[testName] => LIPID PROFILE
[testID] => 4565688
[integrationCode] => BH107G
)

[2] => stdClass Object
(
[testAmount] => 500.0
[testCode] => LIVER FUNCTION TEST
[testCategory] => Immunology
[departmentName] => Lab
[testName] => LIVER FUNCTION TEST
[testID] => 4565742
[integrationCode] => BHL028
)

[3] => stdClass Object
(
[testAmount] => 500
[testCode] => RFT
[testCategory] => Biochemistry
[departmentName] => Lab
[testName] => RFT
[testID] => 4565734
[integrationCode] => 
)

[4] => stdClass Object
(
[testAmount] => 550.0
[testCode] => HBA1C
[testCategory] => Biochemistry
[departmentName] => Lab
[testName] => HBA1C
[testID] => 4565733
[integrationCode] => 
)

[5] => stdClass Object
(
[testAmount] => 1300.0
[testCode] => D-DIMER
[testCategory] => Biochemistry
[departmentName] => Lab
[testName] => D-DIMER
[testID] => 4565719
[integrationCode] => BHD001
)

[6] => stdClass Object
(
[testAmount] => 250.0
[testCode] => PT & INR
[testCategory] => Biochemistry
[departmentName] => Lab
[testName] => PT & INR
[testID] => 4565696
[integrationCode] => BHP063
)

[7] => stdClass Object.....

All this yet I would have to guess this has to be in PHP or something else. Please be specific what system you are coding in.

Line 14 of your code converted the JSON returned from the cURL request into a PHP object.

Typically, you would do something such as $resArr->profileTestList[0]->testCode->testID->name or something roughly like that.

Unfortunately, you did not copy and paste the complete stdClass Object code here, and what you did post is not indented properly, so I'm unable to provide you with the actual answer.

I realized that in your post, you included the URI to fetch the cURL request: https://livehealth.solutions/getAllTestsAndProfiles/?token=3f115cd0-c79b-11eb-b07b-0aa43715764a

Therefore, I'm able to see the complete response and provide you an accurate answer.

profileTestList includes multiple tests (an array of tests). For each test, there is an amount, code, category, list (an array as well), name, ID, and integration code. For each list, there is an amount, code, category, department name, test name, test ID, and integration code.

If you'd like to get the code, ID, and name, of the first test, you can do something such as $resArr->profileTestList[0]->testCode, $resArr->profileTestList[0]->testName, etc. To get the information for the second test, you can do $resArr->profileTestList[1]->testName.

However, for each test in the profile test list, there's also a testList specific to that test ID that contains things like a department name. To get the department name for the first item in testList that is a child of the second profileTestList, do something such as: $resArr->profileTestList[1]->testList[0]->departmentName.

Hope this helps! Good luck :)

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.