3v4l.org

run code in 500+ PHP versions simultaneously
<?php function is_cyclic(array &$array) { json_encode($array); return json_last_error() === JSON_ERROR_RECURSION; } $array = [1, [2, 3]]; $array[1][1] = &$array; var_dump(is_cyclic($array));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3A3Eg
function name:  (null)
number of ops:  11
compiled vars:  !0 = $array
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    8     0  E >   ASSIGN                                                       !0, <array>
    9     1        FETCH_DIM_W                                          $2      !0, 1
          2        FETCH_DIM_W                                          $3      $2, 1
          3        ASSIGN_REF                                                   $3, !0
   10     4        INIT_FCALL                                                   'var_dump'
          5        INIT_FCALL                                                   'is_cyclic'
          6        SEND_REF                                                     !0
          7        DO_FCALL                                          0  $5      
          8        SEND_VAR                                                     $5
          9        DO_ICALL                                                     
         10      > RETURN                                                       1

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

End of function is_cyclic

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
164.13 ms | 3316 KiB | 17 Q