repl.it
@anonymous/

GreenyellowSquareVeery

PHP (Legacy)

No description

fork
loading
main.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
$str = <<<JSON
{
  "playerstats": {
    "steamID": "76561198161582003",
    "gameName": "",
    "stats": [{
        "name": "deaths",
        "value": 604
      },
      {
        "name": "kill",
        "value": 11800
      }
    ]
  }
}
JSON;
$json = json_decode($str);

$name = 'kill';
var_dump($json);

foreach($json->playerstats->stats as $stat){
  if($stat->name === $name){
    $stat->name = "Kill all humans!";
    break;
  }
}

var_dump($json);
PHP 7.0.8 (Legacy: use the following for new features: Command-line PHP: https://repl.it/languages/php_cli PHP Web Server: https://repl.it/languages/php7
?