3v4l.org

run code in 300+ PHP versions simultaneously
<?php $json = <<<EOT [ { "measure":"Walking","record":"steps","latestres":"6870","datet":"2022-08-31" },{ "measure":"","record":"kilograms","latestres":"117","datet":"2022-09-12" },{ "measure":"","record":"","latestres":null,"datet":"2022-09-12" },{ "measure":"Walking","record":"steps","latestres":"6840","datet":"2022-09-12" },{ "measure":"Bodyweight","record":"kilograms","latestres":"92","datet":"2022-09-12" },{ "measure":"Benchpress","record":"kilograms","latestres":"90","datet":"2022-09-12" } ] EOT; $decoded = json_decode($json, true); echo getNthItemFromArray($decoded[0], 2); function getNthItemFromArray(array $array, int $idx) { return $array[array_keys($array)[$idx]]; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/POdma
function name:  (null)
number of ops:  14
compiled vars:  !0 = $json, !1 = $decoded
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%5B%0A%7B%0A++++%22measure%22%3A%22Walking%22%2C%22record%22%3A%22steps%22%2C%22latestres%22%3A%226870%22%2C%22datet%22%3A%222022-08-31%22%0A%7D%2C%7B%0A++++%22measure%22%3A%22%22%2C%22record%22%3A%22kilograms%22%2C%22latestres%22%3A%22117%22%2C%22datet%22%3A%222022-09-12%22%0A%7D%2C%7B%0A++++%22measure%22%3A%22%22%2C%22record%22%3A%22%22%2C%22latestres%22%3Anull%2C%22datet%22%3A%222022-09-12%22%0A%7D%2C%7B%0A++++%22measure%22%3A%22Walking%22%2C%22record%22%3A%22steps%22%2C%22latestres%22%3A%226840%22%2C%22datet%22%3A%222022-09-12%22%0A%7D%2C%7B%0A++++%22measure%22%3A%22Bodyweight%22%2C%22record%22%3A%22kilograms%22%2C%22latestres%22%3A%2292%22%2C%22datet%22%3A%222022-09-12%22%0A%7D%2C%7B%0A++++%22measure%22%3A%22Benchpress%22%2C%22record%22%3A%22kilograms%22%2C%22latestres%22%3A%2290%22%2C%22datet%22%3A%222022-09-12%22%0A%7D%0A%5D'
   21     1        INIT_FCALL                                               'json_decode'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 <true>
          4        DO_ICALL                                         $3      
          5        ASSIGN                                                   !1, $3
   23     6        INIT_FCALL_BY_NAME                                       'getNthItemFromArray'
          7        CHECK_FUNC_ARG                                           
          8        FETCH_DIM_FUNC_ARG                               $5      !1, 0
          9        SEND_FUNC_ARG                                            $5
         10        SEND_VAL_EX                                              2
         11        DO_FCALL                                      0  $6      
         12        ECHO                                                     $6
   28    13      > RETURN                                                   1

Function getnthitemfromarray:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/POdma
function name:  getNthItemFromArray
number of ops:  9
compiled vars:  !0 = $array, !1 = $idx
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   27     2        INIT_FCALL                                               'array_keys'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $2      
          5        FETCH_DIM_R                                      ~3      $2, !1
          6        FETCH_DIM_R                                      ~4      !0, ~3
          7      > RETURN                                                   ~4
   28     8*     > RETURN                                                   null

End of function getnthitemfromarray

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
138.31 ms | 1002 KiB | 15 Q