Save dies das2 - PHP Online

Form of PHP Sandbox

Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php in the places where the PHP script should be executed.



Your result can be seen below.

Result of php executing





Full code of Save dies das2.php

  1. <?php
  2. $jsonData = '[{"teamId":0,"playerId":84632,"playerName":"Flo_McFly","distance":23.660475},{"teamId":2,"playerId":89711,"playerName":"Carlos_Trouble","distance":0.0},{"teamId":2,"playerId":89711,"playerName":"Max_Mustermann (UG)","distance":15.0}]';
  3.  
  4. $data = json_decode($jsonData);
  5. $sortedData = array();
  6.  
  7. foreach ($data as $key => $item) {
  8.    $sortedData[$item->teamId][] = $item;
  9. }
  10.  
  11. ksort($sortedData, SORT_NUMERIC);
  12.  
  13. echo "<pre>".print_r($sortedData, 1)."</pre>";
File Description
  • Save dies das2
  • PHP Code
  • 21 Aug-2023
  • 472 Bytes
You can Share it: