This question already has answers here:
Why does this PHP code just echo "Array"?
(6 answers)
How to extract and access data from JSON with PHP?
(1 answer)
Closed 2 years ago.
I have an JSON Export from a REDCap and it started as a nested ARRAY. I use json_decode, but when I print the result I get an ERROR.
Here is the Array:
[{"record_id":"13","lastname":"Mustermann","first_name":"Json","dob":"1948-10-12","case_number":"1366613"}]
My Code is:
$deco = json_decode($json);
print $deco;
The line "echo" gives an error. What am I doing wrong?!
Thank you
This question already has an answer here:
How to extract and access data from JSON with PHP?
(1 answer)
Closed 5 years ago.
I have a json object array. I want to read the this value. how to read value using php.
My json object Array
[{"employeeId":"ioc-nugegoda","employeeEmail":"lankaioc#lankaioc.com","employeeName":"Colombo","employeePhoneNum":"12345","employeeBrithday":1334946600000,"employeeHomeTown":"ykjld"},{"employeeId":"ioc-nugeqqq","employeeEmail":"lankaioc#lankaioc.com","employeeName":"Colombo","employeePhoneNum":"12345","employeeBrithday":1334946600000,"employeeHomeTown":"ykjld"},{"employeeId":"ioc-nusqq","employeeEmail":"lankaioc#lankaioc.com","employeeName":"Colombo","employeePhoneNum":"12345","employeeBrithday":1334946600000,"employeeHomeTown":"ykjld"}]
$jsonObject = json_decode('{"employeeId":"ioc-nugegoda","employeeEmail":"lankaioc#lankaioc.com","employeeName":"Colombo","employeePhoneNum":"12345","employeeBrithday":1334946600000,"employeeHomeTown":"ykjld"},{"employeeId":"ioc-nugeqqq","employeeEmail":"lankaioc#lankaioc.com","employeeName":"Colombo","employeePhoneNum":"12345","employeeBrithday":1334946600000,"employeeHomeTown":"ykjld"},{"employeeId":"ioc-nusqq","employeeEmail":"lankaioc#lankaioc.com","employeeName":"Colombo","employeePhoneNum":"12345","employeeBrithday":1334946600000,"employeeHomeTown":"ykjld"}');
Which you can find here. After that you can access all values of the json object by its key:
echo $jsonObject["employeeId"];
//Should return: ioc-nugegoda
If you have an array arround your JsonObject you need to access the object itself first.. this would look like:
echo $jsonObject[0]["employeeId"];
This question already has answers here:
print_r() adds properties to DateTime objects [duplicate]
(7 answers)
Why can't I access DateTime->date in PHP's DateTime class?
(5 answers)
Closed 5 years ago.
Can anyone explain why these two pieces of code act differently and what I'm doing wrong:
print_r($user['first_signed_up_date']);
echo $user['first_signed_up_date']->milliseconds/1000;
Result:
MongoDB\BSON\UTCDateTime Object
(
[milliseconds] => 1507976375000
)
1507976375
Second code:
// removed print_r / var_dump
echo $user['first_signed_up_date']->milliseconds/1000;
Result:
0
The only difference between first and second code is there's no print_r (var_dump has same result)
This question already has answers here:
How to loop through PHP object with dynamic keys [duplicate]
(16 answers)
How to extract and access data from JSON with PHP?
(1 answer)
Closed 5 years ago.
I want to get the URLS from the JSON below.
$jsonArray = {
"uuid": "signed",
"PreSigned": "{'url': ['www.g.com', 'www.o.com']"}
I tried this $jsonArray -> PreSigned[0]->url
And it didn't work
This question already has answers here:
PHP Object Property has brackets in it
(2 answers)
Closed 9 years ago.
I'm doing a print_r on an object that is returned after running a query. Here is my print_r log.
stdClass Object
(
[MAX(sort_order)] => 3
)
I want to get the value inside [MAX(sort_order)] but I cant figure out how to target it from within php.
Like $sort_order = $object->[MAX(sort_order)]; (I know that won't work)
Does anyone know how I can do this?
Try add this in your query MAX(sort_order) AS max_sort_order in your query