3v4l.org

run code in 300+ PHP versions simultaneously
<?php $url = 'www.example.com/title/page/article/'; //this is the URL $urlArray = explode('/', $url); //Strip down the URL $startURL = $urlArray[0]; //we want to keep this for if the user clicks on start. $urlArray[0] = 'Start'; //replace www.example.com with "start" if($urlArray[count($urlArray) - 1] == ''){ //this checks the last item is being empty or not. array_pop($urlArray); //last item is indeed empty so we just remove it. } $broadCrumb = ''; //create an empty broadCrumb variable Foreach($urlArray as $index =>$value){ //loop through the stripped down url $value = ucfirst($value); //initcap the items $broadCrumbTemp = '<a href="'.$startURL.'/{url}">{linkname}</a>{delimeter}'; //this is the template we are going to use. if($index == (count($urlArray) - 1)){ //if the index is last $broadCrumb .= $value; //just append the item }else{ //if the index isn't last $location = ''; for($i = 1; $i <= $index; $i++){ $location .= $urlArray[$i].'/'; } $replace = array('{url}', '{linkname}', '{delimeter}'); $replaceTo = array($location, $value, ' > '); $broadCrumbTemp = str_ireplace($replace, $replaceTo, $broadCrumbTemp); $broadCrumb .= $broadCrumbTemp; } } echo($broadCrumb); //show the broadCrumb
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 18
Branch analysis from position: 15
2 jumps found. (Code = 77) Position 1 = 20, Position 2 = 57
Branch analysis from position: 20
2 jumps found. (Code = 78) Position 1 = 21, Position 2 = 57
Branch analysis from position: 21
2 jumps found. (Code = 43) Position 1 = 33, Position 2 = 35
Branch analysis from position: 33
1 jumps found. (Code = 42) Position 1 = 56
Branch analysis from position: 56
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
Branch analysis from position: 35
1 jumps found. (Code = 42) Position 1 = 42
Branch analysis from position: 42
2 jumps found. (Code = 44) Position 1 = 44, Position 2 = 38
Branch analysis from position: 44
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
Branch analysis from position: 38
2 jumps found. (Code = 44) Position 1 = 44, Position 2 = 38
Branch analysis from position: 44
Branch analysis from position: 38
Branch analysis from position: 57
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 57
Branch analysis from position: 18
filename:       /in/D0bPG
function name:  (null)
number of ops:  60
compiled vars:  !0 = $url, !1 = $urlArray, !2 = $startURL, !3 = $broadCrumb, !4 = $value, !5 = $index, !6 = $broadCrumbTemp, !7 = $location, !8 = $i, !9 = $replace, !10 = $replaceTo
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, 'www.example.com%2Ftitle%2Fpage%2Farticle%2F'
    3     1        INIT_FCALL                                               'explode'
          2        SEND_VAL                                                 '%2F'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $12     
          5        ASSIGN                                                   !1, $12
    4     6        FETCH_DIM_R                                      ~14     !1, 0
          7        ASSIGN                                                   !2, ~14
    5     8        ASSIGN_DIM                                               !1, 0
          9        OP_DATA                                                  'Start'
    6    10        COUNT                                            ~17     !1
         11        SUB                                              ~18     ~17, 1
         12        FETCH_DIM_R                                      ~19     !1, ~18
         13        IS_EQUAL                                                 ~19, ''
         14      > JMPZ                                                     ~20, ->18
    7    15    >   INIT_FCALL                                               'array_pop'
         16        SEND_REF                                                 !1
         17        DO_ICALL                                                 
    9    18    >   ASSIGN                                                   !3, ''
   10    19      > FE_RESET_R                                       $23     !1, ->57
         20    > > FE_FETCH_R                                       ~24     $23, !4, ->57
         21    >   ASSIGN                                                   !5, ~24
   11    22        INIT_FCALL                                               'ucfirst'
         23        SEND_VAR                                                 !4
         24        DO_ICALL                                         $26     
         25        ASSIGN                                                   !4, $26
   13    26        CONCAT                                           ~28     '%3Ca+href%3D%22', !2
         27        CONCAT                                           ~29     ~28, '%2F%7Burl%7D%22%3E%7Blinkname%7D%3C%2Fa%3E%7Bdelimeter%7D'
         28        ASSIGN                                                   !6, ~29
   15    29        COUNT                                            ~31     !1
         30        SUB                                              ~32     ~31, 1
         31        IS_EQUAL                                                 !5, ~32
         32      > JMPZ                                                     ~33, ->35
   16    33    >   ASSIGN_OP                                     8          !3, !4
         34      > JMP                                                      ->56
   19    35    >   ASSIGN                                                   !7, ''
   20    36        ASSIGN                                                   !8, 1
         37      > JMP                                                      ->42
   21    38    >   FETCH_DIM_R                                      ~37     !1, !8
         39        CONCAT                                           ~38     ~37, '%2F'
         40        ASSIGN_OP                                     8          !7, ~38
   20    41        PRE_INC                                                  !8
         42    >   IS_SMALLER_OR_EQUAL                                      !8, !5
         43      > JMPNZ                                                    ~41, ->38
   23    44    >   ASSIGN                                                   !9, <array>
   24    45        INIT_ARRAY                                       ~43     !7
         46        ADD_ARRAY_ELEMENT                                ~43     !4
         47        ADD_ARRAY_ELEMENT                                ~43     '+%3E+'
         48        ASSIGN                                                   !10, ~43
   25    49        INIT_FCALL                                               'str_ireplace'
         50        SEND_VAR                                                 !9
         51        SEND_VAR                                                 !10
         52        SEND_VAR                                                 !6
         53        DO_ICALL                                         $45     
         54        ASSIGN                                                   !6, $45
   26    55        ASSIGN_OP                                     8          !3, !6
   10    56    > > JMP                                                      ->20
         57    >   FE_FREE                                                  $23
   30    58        ECHO                                                     !3
         59      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
174.12 ms | 1405 KiB | 21 Q