3v4l.org

run code in 300+ PHP versions simultaneously
<?php $jsonData = '[{"id":"1","component":"crank","brand":"part1","date_":"13\/11\/2019"},{"id":"2","component":"rim","date_":"13\/11\/2019","location":"Front","servicetype":"part 2"},{"id":"3","component":"bar","brand":"part 3","date_":"13\/11\/2019"}]'; $id = 2; $dataToSort = json_decode($jsonData); foreach($dataToSort as $Key => $element) { if ($element->id == $id) { unset($dataToSort[$Key]); echo $id . " Deleted\n"; } } $newJsonData = json_encode(array_values($dataToSort), JSON_PRETTY_PRINT); echo $newJsonData;
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 16
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 16
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 15
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 15
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
filename:       /in/tJBDE
function name:  (null)
number of ops:  27
compiled vars:  !0 = $jsonData, !1 = $id, !2 = $dataToSort, !3 = $element, !4 = $Key, !5 = $newJsonData
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%5B%7B%22id%22%3A%221%22%2C%22component%22%3A%22crank%22%2C%22brand%22%3A%22part1%22%2C%22date_%22%3A%2213%5C%2F11%5C%2F2019%22%7D%2C%7B%22id%22%3A%222%22%2C%22component%22%3A%22rim%22%2C%22date_%22%3A%2213%5C%2F11%5C%2F2019%22%2C%22location%22%3A%22Front%22%2C%22servicetype%22%3A%22part+2%22%7D%2C%7B%22id%22%3A%223%22%2C%22component%22%3A%22bar%22%2C%22brand%22%3A%22part+3%22%2C%22date_%22%3A%2213%5C%2F11%5C%2F2019%22%7D%5D'
    4     1        ASSIGN                                                   !1, 2
    6     2        INIT_FCALL                                               'json_decode'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $8      
          5        ASSIGN                                                   !2, $8
    8     6      > FE_RESET_R                                       $10     !2, ->16
          7    > > FE_FETCH_R                                       ~11     $10, !3, ->16
          8    >   ASSIGN                                                   !4, ~11
    9     9        FETCH_OBJ_R                                      ~13     !3, 'id'
         10        IS_EQUAL                                                 !1, ~13
         11      > JMPZ                                                     ~14, ->15
   10    12    >   UNSET_DIM                                                !2, !4
   11    13        CONCAT                                           ~15     !1, '+Deleted%0A'
         14        ECHO                                                     ~15
    8    15    > > JMP                                                      ->7
         16    >   FE_FREE                                                  $10
   15    17        INIT_FCALL                                               'json_encode'
         18        INIT_FCALL                                               'array_values'
         19        SEND_VAR                                                 !2
         20        DO_ICALL                                         $16     
         21        SEND_VAR                                                 $16
         22        SEND_VAL                                                 128
         23        DO_ICALL                                         $17     
         24        ASSIGN                                                   !5, $17
   17    25        ECHO                                                     !5
   18    26      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.38 ms | 1013 KiB | 16 Q