json php (Problems trying to exctract values) [closed] - php
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
Hope someone can help me :)
I have a json to decode and i want to get some values in it but, i fail trying ...
The json to decode is this one :
$string = '{"TEAM-d2dbb890-813d-11e3-9ae1-782bcb4ce61a":{"fullId":"TEAM-d2dbb890-813d-11e3-9ae1-782bcb4ce61a","name":"La line Up","tag":"LILU","status":"RANKED","teamStatSummary":{"fullId":"TEAM-d2dbb890-813d-11e3-9ae1-782bcb4ce61a","teamStatDetails":[{"fullId":"TEAM-d2dbb890-813d-11e3-9ae1-782bcb4ce61a","teamStatType":"RANKED_TEAM_5x5","wins":4,"losses":2,"averageGamesPlayed":0},{"fullId":"TEAM-d2dbb890-813d-11e3-9ae1-782bcb4ce61a","teamStatType":"RANKED_TEAM_3x3","wins":0,"losses":0,"averageGamesPlayed":0}]},"roster":{"ownerId":21428398,"memberList":[{"playerId":23907761,"joinDate":1390159075000,"inviteDate":1390158849000,"status":"MEMBER"},{"playerId":21075924,"joinDate":1390158942000,"inviteDate":1390158852000,"status":"MEMBER"},{"playerId":21428398,"joinDate":1390158907000,"inviteDate":1390158856000,"status":"MEMBER"},{"playerId":29513977,"joinDate":1390158926000,"inviteDate":1390158911000,"status":"MEMBER"}]},"matchHistory":[{"kills":30,"deaths":51,"opposingTeamKills":51,"assists":50,"gameMode":"CLASSIC","opposingTeamName":"stavaclaroxd","win":false,"invalid":false,"mapId":1,"gameId":1284144814,"date":1390258314682},{"kills":9,"deaths":24,"opposingTeamKills":24,"assists":12,"gameMode":"CLASSIC","opposingTeamName":"Infinity gaming v2","win":false,"invalid":false,"mapId":1,"gameId":1282462494,"date":1390169929005},{"kills":32,"deaths":9,"opposingTeamKills":9,"assists":53,"gameMode":"CLASSIC","opposingTeamName":"Suburban Syndicate Squad","win":true,"invalid":false,"mapId":1,"gameId":1282421677,"date":1390167736333},{"kills":22,"deaths":3,"opposingTeamKills":3,"assists":32,"gameMode":"CLASSIC","opposingTeamName":"SKTlT5","win":true,"invalid":false,"mapId":1,"gameId":1282362755,"date":1390165366740},{"kills":24,"deaths":9,"opposingTeamKills":9,"assists":35,"gameMode":"CLASSIC","opposingTeamName":"нELLO HELLо","win":true,"invalid":false,"mapId":1,"gameId":1282304277,"date":1390163366886},{"kills":35,"deaths":11,"opposingTeamKills":11,"assists":58,"gameMode":"CLASSIC","opposingTeamName":"нELLO HELLо","win":true,"invalid":true,"mapId":1,"gameId":1282260799,"date":1390161678373}],"createDate":1390158828000,"modifyDate":1392723897000,"lastJoinDate":1390159075000,"secondLastJoinDate":1390158942000,"thirdLastJoinDate":1390158926000,"lastGameDate":1390422192000,"lastJoinedRankedTeamQueueDate":1390421982000}}';
I did something but with no result :
$json_a=json_decode($string,true);
$json_a[TEAM-d2dbb890-813d-11e3-9ae1-782bcb4ce61a][name]
That was a fail ... if someone can help me, I would be happy :)
Best regards,
CUETO Vincent
echo the value
echo $json_a['TEAM-d2dbb890-813d-11e3-9ae1-782bcb4ce61a']['name'];
This is not an array, but stdclass - {} not [].
Try:
$json_a->{'TEAM-d2dbb890-813d-11e3-9ae1-782bcb4ce61a'}->name
Related
Get Value of array with multiple values [closed]
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers. This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers. Closed 1 year ago. Improve this question i know that has to be a trivial one. Can please somebody tell me how only to get the value of skills? how can i access it? Appreciate.
You have different options to choose from: In plain PHP you can do: $skills = array_map(function($entry) { return $entry->skills; }, $arr); With Laravel helpers you can do: Arr::pluck($arr, 'skills'); Your data looks like models so in that case, you might be able to do this as well: YourModel::get()->pluck('skills'); //or $yourCollection->pluck('skills');
How to Concatenate a PHP variable and a string [closed]
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers. This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers. Closed 6 years ago. Improve this question might be a very dumb question but i'm trying to make a html string with a php var and then html.. what the heck am I doing wrong?!? :( $author_name = get_the_author(); ?> <h4><?php $author_name;?> On-Demand Webinars</h4> Thank you!
Just missed the echo. <h4><?php echo $author_name;?> On-Demand Webinars</h4>
You missed "echo" statement e.g <?php echo $author_name;?> On-Demand Webinars OR <?=$author_name;?>
Php help find where is syntax error [closed]
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers. This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers. Closed 8 years ago. Improve this question foreach($db->fetch_array("SELECT id_categories FROM csn_categories_join_kartes where id_kartes===".$card['id']."") as $kat){ echo (kat['id_categories']); } table cols and values are all matched, something is wrong in this part of code I tried adding $ before kat and using only one "=", sill doesnt work NEW LINK http://pastebin.com/RPK7vEaJ
this where id_kartes===".$card['id']." would be where id_kartes=".$card['id']." and missing $ echo $kat['id_categories']; so full code :- foreach($db->fetch_array("SELECT id_categories FROM csn_categories_join_kartes where id_kartes='".$card['id']."'") as $kat){ echo $kat['id_categories']; } best practice if you store your query result in a variable and loop over this variable.
foreach($db->fetch_array("SELECT id_categories FROM csn_categories_join_kartes where id_kartes=".$card['id']."") as $kat)
PHP error for login session [closed]
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers. This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers. Closed 8 years ago. Improve this question I have an error in a single line of code but I can't seem to find it. I've tried changing the quotes to all match but that doesn't do anything. Please help. here is where the error is $managerID = preg_replace('#[^0-9]#i',",$_SESSION["id"]);
try this : $managerID = preg_replace('#[^0-9]#i','',$_SESSION["id"]); btw i dont know what you are trying to do i just solved your syntax error ;)
PHP: Parse error: syntax error, unexpected 'http' (T_STRING) in [closed]
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers. This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers. Closed 8 years ago. Improve this question Without getting into too much details on my project, I'm currently trying to use PHP to download a remote file and store it in the current directory on the server. Please keep in mind I do not know much of anything about PHP and am trying to learn. I'm using the following code: <?php file_get_contents(''http://xxx.xx.xx/file.php/'');?> As you can see, this is pretty basic, and I'm not even really sure if it will get the job done. Any help is greatly appreciated!
Try this: <?php file_get_contents("http://xxx.xx.xx/file.php");?>