'Describe php object
I want to create a function that will do this: check the object and if the property 1 is 001 then print John else if the property 2 is 002 the print Jenny but I dont know how to read the property 1 [001] and describe it as a variable.
The result that I cURL from a file:
stdClass Object
(
[id] => stdClass Object
(
[001] => John
[002] => Jenny
)
)
Solution 1:[1]
Check if the id is present in your object and if it is return the name. As an example:
function get_name_from_id($obj, $id) {
return $obj->id->$id ?? false;
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | AbraCadaver |
