3v4l.org

run code in 300+ PHP versions simultaneously
<?php $sections = array( array( 'name' => 'home', 'uri' => '/', 'title' => 'home'), array( 'name' => 'tech', 'uri' => '/tech', 'title' => 'ux/ui' ), array( 'name' => 'monetization', 'uri' => '/monetization', 'title' => 'monetization' ), array( 'name' => 'contact', 'uri' => '/contact', 'title' => 'contact', 'callToAction' => true, 'desktopTitle' => 'contact us' ), array( 'name' => 'blog', 'uri' => 'https://blog.marfeel.com/blog', 'title' => 'blog', 'external' => true), ); function callToActions($section) { return $section["callToAction"]; } function defaultSections($section) { return !$section["callToAction"]; } function buildSections ($sections) { $index = count($sections); while($index) { $section = $sections[--$index]; print_r($section); echo '<li> <a href="'. $section["uri"] . '">' . ($section["desktopTitle"]? ucfirst($section["desktopTitle"]): ucfirst($section["title"])) . '</a> </li>'; } } buildSections(array_filter($sections, callToActions)); //print_r(array_filter($sections, defaultSections));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/niMSr
function name:  (null)
number of ops:  10
compiled vars:  !0 = $sections
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
   33     1        INIT_FCALL                                               'buildsections'
          2        INIT_FCALL                                               'array_filter'
          3        SEND_VAR                                                 !0
          4        FETCH_CONSTANT                                   ~2      'callToActions'
          5        SEND_VAL                                                 ~2
          6        DO_ICALL                                         $3      
          7        SEND_VAR                                                 $3
          8        DO_FCALL                                      0          
   34     9      > RETURN                                                   1

Function calltoactions:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/niMSr
function name:  callToActions
number of ops:  4
compiled vars:  !0 = $section
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
   12     1        FETCH_DIM_R                                      ~1      !0, 'callToAction'
          2      > RETURN                                                   ~1
   13     3*     > RETURN                                                   null

End of function calltoactions

Function defaultsections:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/niMSr
function name:  defaultSections
number of ops:  5
compiled vars:  !0 = $section
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   RECV                                             !0      
   17     1        FETCH_DIM_R                                      ~1      !0, 'callToAction'
          2        BOOL_NOT                                         ~2      ~1
          3      > RETURN                                                   ~2
   18     4*     > RETURN                                                   null

End of function defaultsections

Function buildsections:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
2 jumps found. (Code = 44) Position 1 = 30, Position 2 = 4
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 21
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
2 jumps found. (Code = 44) Position 1 = 30, Position 2 = 4
Branch analysis from position: 30
Branch analysis from position: 4
Branch analysis from position: 21
2 jumps found. (Code = 44) Position 1 = 30, Position 2 = 4
Branch analysis from position: 30
Branch analysis from position: 4
filename:       /in/niMSr
function name:  buildSections
number of ops:  31
compiled vars:  !0 = $sections, !1 = $index, !2 = $section
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   RECV                                             !0      
   21     1        COUNT                                            ~3      !0
          2        ASSIGN                                                   !1, ~3
   23     3      > JMP                                                      ->29
   24     4    >   PRE_DEC                                          ~5      !1
          5        FETCH_DIM_R                                      ~6      !0, ~5
          6        ASSIGN                                                   !2, ~6
   25     7        INIT_FCALL                                               'print_r'
          8        SEND_VAR                                                 !2
          9        DO_ICALL                                                 
   28    10        FETCH_DIM_R                                      ~9      !2, 'uri'
         11        CONCAT                                           ~10     '%3Cli%3E%0A++++++++++++++++++++++++++++++++++++++++%3Ca+href%3D%22', ~9
         12        CONCAT                                           ~11     ~10, '%22%3E'
         13        FETCH_DIM_R                                      ~12     !2, 'desktopTitle'
         14      > JMPZ                                                     ~12, ->21
         15    >   INIT_FCALL                                               'ucfirst'
         16        FETCH_DIM_R                                      ~13     !2, 'desktopTitle'
         17        SEND_VAL                                                 ~13
         18        DO_ICALL                                         $14     
         19        QM_ASSIGN                                        ~15     $14
         20      > JMP                                                      ->26
         21    >   INIT_FCALL                                               'ucfirst'
         22        FETCH_DIM_R                                      ~16     !2, 'title'
         23        SEND_VAL                                                 ~16
         24        DO_ICALL                                         $17     
         25        QM_ASSIGN                                        ~15     $17
         26    >   CONCAT                                           ~18     ~11, ~15
         27        CONCAT                                           ~19     ~18, '%3C%2Fa%3E%0A++++++++++++++++++++++++++++++++++++%3C%2Fli%3E'
         28        ECHO                                                     ~19
   23    29    > > JMPNZ                                                    !1, ->4
   31    30    > > RETURN                                                   null

End of function buildsections

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.62 ms | 1403 KiB | 20 Q