3v4l.org

run code in 300+ PHP versions simultaneously
<?php function esc_url($string) { return $string; // just preventing demo breakage } function get_term_link($wpObject) { return 'https://www.example.com/' . $wpObject->slug; } $tipologiaTerms = [ (object) ['term_id' => 1, 'name' => 'racconti sulla vita', 'slug' => 'racconti-sulla-vita', 'taxonomy' => 'category'], (object) ['term_id' => 2, 'name' => 'racconti di passione', 'slug' => 'racconti-di-passione', 'taxonomy' => 'category'], (object) ['term_id' => 3, 'name' => 'sulle amotivazionali', 'slug' => 'sulle-amotivazionali', 'taxonomy' => 'category'], (object) ['term_id' => 4, 'name' => 'boem sulle', 'slug' => 'boem-sulle', 'taxonomy' => 'category'], (object) ['term_id' => 5, 'name' => 'racconti sui pensieri', 'slug' => 'racconti-sui-pensieri', 'taxonomy' => 'category'], (object) ['term_id' => 6, 'name' => 'racconti motivazionali', 'slug' => 'racconti-motivazionali', 'taxonomy' => 'category'], ]; $blacklist = ["racconti", "sul", "sull'", "sulla", "sulle", "sullo", "sui", "di"]; $pattern = '/\b(?:' . implode('|', $blacklist) . ')\b\s?/i'; $cleanNames = []; foreach ($tipologiaTerms as $wpTerm) { $wpTerm->name = rtrim(preg_replace($pattern, '', $wpTerm->name)); $cleanNames[] = $wpTerm->name; } array_multisort($cleanNames, $tipologiaTerms); foreach ($tipologiaTerms as $wpTerm) { printf( '<li><a href="%s">%s</a></li>' . "\n", esc_url(get_term_link($wpTerm)), $wpTerm->name ); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 23, Position 2 = 39
Branch analysis from position: 23
2 jumps found. (Code = 78) Position 1 = 24, Position 2 = 39
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
Branch analysis from position: 39
2 jumps found. (Code = 77) Position 1 = 45, Position 2 = 59
Branch analysis from position: 45
2 jumps found. (Code = 78) Position 1 = 46, Position 2 = 59
Branch analysis from position: 46
1 jumps found. (Code = 42) Position 1 = 45
Branch analysis from position: 45
Branch analysis from position: 59
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 59
Branch analysis from position: 39
filename:       /in/GILcF
function name:  (null)
number of ops:  61
compiled vars:  !0 = $tipologiaTerms, !1 = $blacklist, !2 = $pattern, !3 = $cleanNames, !4 = $wpTerm
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   CAST                                          8  ~5      <array>
          1        INIT_ARRAY                                       ~6      ~5
   13     2        CAST                                          8  ~7      <array>
          3        ADD_ARRAY_ELEMENT                                ~6      ~7
   14     4        CAST                                          8  ~8      <array>
          5        ADD_ARRAY_ELEMENT                                ~6      ~8
   15     6        CAST                                          8  ~9      <array>
          7        ADD_ARRAY_ELEMENT                                ~6      ~9
   16     8        CAST                                          8  ~10     <array>
          9        ADD_ARRAY_ELEMENT                                ~6      ~10
   17    10        CAST                                          8  ~11     <array>
         11        ADD_ARRAY_ELEMENT                                ~6      ~11
   11    12        ASSIGN                                                   !0, ~6
   20    13        ASSIGN                                                   !1, <array>
   21    14        INIT_FCALL                                               'implode'
         15        SEND_VAL                                                 '%7C'
         16        SEND_VAR                                                 !1
         17        DO_ICALL                                         $14     
         18        CONCAT                                           ~15     '%2F%5Cb%28%3F%3A', $14
         19        CONCAT                                           ~16     ~15, '%29%5Cb%5Cs%3F%2Fi'
         20        ASSIGN                                                   !2, ~16
   22    21        ASSIGN                                                   !3, <array>
   23    22      > FE_RESET_R                                       $19     !0, ->39
         23    > > FE_FETCH_R                                               $19, !4, ->39
   24    24    >   INIT_FCALL                                               'rtrim'
         25        INIT_FCALL                                               'preg_replace'
         26        SEND_VAR                                                 !2
         27        SEND_VAL                                                 ''
         28        FETCH_OBJ_R                                      ~21     !4, 'name'
         29        SEND_VAL                                                 ~21
         30        DO_ICALL                                         $22     
         31        SEND_VAR                                                 $22
         32        DO_ICALL                                         $23     
         33        ASSIGN_OBJ                                               !4, 'name'
         34        OP_DATA                                                  $23
   25    35        FETCH_OBJ_R                                      ~25     !4, 'name'
         36        ASSIGN_DIM                                               !3
         37        OP_DATA                                                  ~25
   23    38      > JMP                                                      ->23
         39    >   FE_FREE                                                  $19
   27    40        INIT_FCALL                                               'array_multisort'
         41        SEND_REF                                                 !3
         42        SEND_REF                                                 !0
         43        DO_ICALL                                                 
   29    44      > FE_RESET_R                                       $27     !0, ->59
         45    > > FE_FETCH_R                                               $27, !4, ->59
   30    46    >   INIT_FCALL                                               'printf'
   31    47        SEND_VAL                                                 '%3Cli%3E%3Ca+href%3D%22%25s%22%3E%25s%3C%2Fa%3E%3C%2Fli%3E%0A'
   32    48        INIT_FCALL                                               'esc_url'
         49        INIT_FCALL                                               'get_term_link'
         50        SEND_VAR                                                 !4
         51        DO_FCALL                                      0  $28     
         52        SEND_VAR                                                 $28
         53        DO_FCALL                                      0  $29     
         54        SEND_VAR                                                 $29
   33    55        FETCH_OBJ_R                                      ~30     !4, 'name'
         56        SEND_VAL                                                 ~30
   30    57        DO_ICALL                                                 
   29    58      > JMP                                                      ->45
         59    >   FE_FREE                                                  $27
   35    60      > RETURN                                                   1

Function esc_url:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/GILcF
function name:  esc_url
number of ops:  3
compiled vars:  !0 = $string
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1      > RETURN                                                   !0
    5     2*     > RETURN                                                   null

End of function esc_url

Function get_term_link:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/GILcF
function name:  get_term_link
number of ops:  5
compiled vars:  !0 = $wpObject
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
    8     1        FETCH_OBJ_R                                      ~1      !0, 'slug'
          2        CONCAT                                           ~2      'https%3A%2F%2Fwww.example.com%2F', ~1
          3      > RETURN                                                   ~2
    9     4*     > RETURN                                                   null

End of function get_term_link

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
162 ms | 1022 KiB | 20 Q