Reputation: 65
{"data":{"tokenId":"cbad508f88a2a8ff47c75426338026de"},"success":true,"error":{"errorCode":"200","errorMsg":"successfully"}}
{"referredBy":"Dvbrhhv","deviceId":"488014664955832","msisdn":"8358808909"}
And I want to echo only tokenId from this data in php how can i initiate kindly help me out
Upvotes: 2
Views: 142
Reputation: 685
You can get it
$jsonResult = json_decode($json ,true);
echo $jsonResult['data']['tokenId'];
You can see result
<br/>
output : cbad508f88a2a8ff47c75426338026de
Upvotes: 0
Reputation: 6661
Your json
is not valid json
please check your json on this link
$json='{
"data": {
"tokenId": "cbad508f88a2a8ff47c75426338026de"
},
"success": true,
"error": {
"errorCode": "200",
"errorMsg": "successfully"
}
}';
$json=json_decode($json);
echo $json->data->tokenId;
use json_decode
Demo
Upvotes: 1