3v4l.org

run code in 300+ PHP versions simultaneously
<?php function x_the_image( $post_id ) { $attachment_ids = array( 1, 2, 3, 4 ); $next_id = -1; foreach ( $attachment_ids as $attachment_id ) { if ( $attachment_id == $post_id ) { $next_id = current( $attachment_ids ); break; } } return $next_id; } var_dump( x_the_image(2) === 3, x_the_image(3) === 4, x_the_image(4) === 1, x_the_image(5) );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/oQiI9
function name:  (null)
number of ops:  22
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   INIT_FCALL                                               'var_dump'
          1        INIT_FCALL                                               'x_the_image'
          2        SEND_VAL                                                 2
          3        DO_FCALL                                      0  $0      
          4        IS_IDENTICAL                                     ~1      $0, 3
          5        SEND_VAL                                                 ~1
          6        INIT_FCALL                                               'x_the_image'
          7        SEND_VAL                                                 3
          8        DO_FCALL                                      0  $2      
          9        IS_IDENTICAL                                     ~3      $2, 4
         10        SEND_VAL                                                 ~3
         11        INIT_FCALL                                               'x_the_image'
         12        SEND_VAL                                                 4
         13        DO_FCALL                                      0  $4      
         14        IS_IDENTICAL                                     ~5      $4, 1
         15        SEND_VAL                                                 ~5
         16        INIT_FCALL                                               'x_the_image'
         17        SEND_VAL                                                 5
         18        DO_FCALL                                      0  $6      
         19        SEND_VAR                                                 $6
         20        DO_ICALL                                                 
         21      > RETURN                                                   1

Function x_the_image:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 13
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 13
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 12
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 13
Branch analysis from position: 13
filename:       /in/oQiI9
function name:  x_the_image
number of ops:  16
compiled vars:  !0 = $post_id, !1 = $attachment_ids, !2 = $next_id, !3 = $attachment_id
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        ASSIGN                                                   !1, <array>
    5     2        ASSIGN                                                   !2, -1
    6     3      > FE_RESET_R                                       $6      !1, ->13
          4    > > FE_FETCH_R                                               $6, !3, ->13
    7     5    >   IS_EQUAL                                                 !3, !0
          6      > JMPZ                                                     ~7, ->12
    8     7    >   INIT_FCALL                                               'current'
          8        SEND_VAR                                                 !1
          9        DO_ICALL                                         $8      
         10        ASSIGN                                                   !2, $8
    9    11      > JMP                                                      ->13
    6    12    > > JMP                                                      ->4
         13    >   FE_FREE                                                  $6
   12    14      > RETURN                                                   !2
   13    15*     > RETURN                                                   null

End of function x_the_image

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
139.5 ms | 1468 KiB | 19 Q