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]; 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/N8j6e
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>
   32     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          
   33     9      > RETURN                                                   1

Function calltoactions:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/N8j6e
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/N8j6e
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 = 26
Branch analysis from position: 26
2 jumps found. (Code = 44) Position 1 = 27, Position 2 = 4
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 18
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
2 jumps found. (Code = 44) Position 1 = 27, Position 2 = 4
Branch analysis from position: 27
Branch analysis from position: 4
Branch analysis from position: 18
2 jumps found. (Code = 44) Position 1 = 27, Position 2 = 4
Branch analysis from position: 27
Branch analysis from position: 4
filename:       /in/N8j6e
function name:  buildSections
number of ops:  28
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                                                      ->26
   24     4    >   PRE_DEC                                          ~5      !1
          5        FETCH_DIM_R                                      ~6      !0, ~5
          6        ASSIGN                                                   !2, ~6
   27     7        FETCH_DIM_R                                      ~8      !2, 'uri'
          8        CONCAT                                           ~9      '%3Cli%3E%0A++++++++++++++++++++++++++++++++++++++++%3Ca+href%3D%22', ~8
          9        CONCAT                                           ~10     ~9, '%22%3E'
         10        FETCH_DIM_R                                      ~11     !2, 'desktopTitle'
         11      > JMPZ                                                     ~11, ->18
         12    >   INIT_FCALL                                               'ucfirst'
         13        FETCH_DIM_R                                      ~12     !2, 'desktopTitle'
         14        SEND_VAL                                                 ~12
         15        DO_ICALL                                         $13     
         16        QM_ASSIGN                                        ~14     $13
         17      > JMP                                                      ->23
         18    >   INIT_FCALL                                               'ucfirst'
         19        FETCH_DIM_R                                      ~15     !2, 'title'
         20        SEND_VAL                                                 ~15
         21        DO_ICALL                                         $16     
         22        QM_ASSIGN                                        ~14     $16
         23    >   CONCAT                                           ~17     ~10, ~14
         24        CONCAT                                           ~18     ~17, '%3C%2Fa%3E%0A++++++++++++++++++++++++++++++++++++%3C%2Fli%3E'
         25        ECHO                                                     ~18
   23    26    > > JMPNZ                                                    !1, ->4
   30    27    > > RETURN                                                   null

End of function buildsections

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
183.37 ms | 948 KiB | 19 Q