3v4l.org

run code in 300+ PHP versions simultaneously
<?php $geos = array( array( "type" => "STATE", "state" => "TX" ), array( "type" => "STATE", "state" => "MI" ), array( "type" => "STATE", "state" => "CA" ) ); $geos = array( array( "type" => "DMA", "dma" => 635 ), array( "type" => "DMA", "dma" => 618 ), array( "type" => "DMA", "dma" => 803 ) ); $geos = array( array( "type"=> "CITY", "state"=> "TX", "city"=> "Austin" ), array( "type"=> "CITY", "state"=> "MI", "city"=> "East Lansing" ), array( "type"=> "CITY", "state"=> "TX", "city"=> "Houston" ) ); // figure out type $geoValues = array(); $geoTypeUppercase = count($geos) ? $geos[0]['type'] : null; if ($geoTypeUppercase === 'CITY') { $geoValues = array_map(function($geo) { return $geo['city'] . ', ' . $geo['state']; }, $geos); } else if (in_array($geoTypeUppercase, array('STATE', 'DMA'))) { $geoValues = array_map(function($geo) use ($geoTypeUppercase) { return $geo[strtolower($geoTypeUppercase)]; }, $geos); } if (count($geoValues)) { print_r($geoTypeUppercase); $geoType = 'geoType' . ucword($geoTypeUppercase); print_r($geoType); print_r($geoValues); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 10
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 21
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 30
Branch analysis from position: 30
2 jumps found. (Code = 43) Position 1 = 32, Position 2 = 46
Branch analysis from position: 32
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 46
Branch analysis from position: 21
2 jumps found. (Code = 43) Position 1 = 23, Position 2 = 30
Branch analysis from position: 23
2 jumps found. (Code = 43) Position 1 = 32, Position 2 = 46
Branch analysis from position: 32
Branch analysis from position: 46
Branch analysis from position: 30
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 21
Branch analysis from position: 14
Branch analysis from position: 21
filename:       /in/odAKT
function name:  (null)
number of ops:  47
compiled vars:  !0 = $geos, !1 = $geoValues, !2 = $geoTypeUppercase, !3 = $geoType
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   18     1        ASSIGN                                                   !0, <array>
   33     2        ASSIGN                                                   !0, <array>
   53     3        ASSIGN                                                   !1, <array>
   54     4        COUNT                                            ~8      !0
          5      > JMPZ                                                     ~8, ->10
          6    >   FETCH_DIM_R                                      ~9      !0, 0
          7        FETCH_DIM_R                                      ~10     ~9, 'type'
          8        QM_ASSIGN                                        ~11     ~10
          9      > JMP                                                      ->11
         10    >   QM_ASSIGN                                        ~11     null
         11    >   ASSIGN                                                   !2, ~11
   56    12        IS_IDENTICAL                                             !2, 'CITY'
         13      > JMPZ                                                     ~13, ->21
   57    14    >   INIT_FCALL                                               'array_map'
         15        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FodAKT%3A57%240'
   59    16        SEND_VAL                                                 ~14
         17        SEND_VAR                                                 !0
         18        DO_ICALL                                         $15     
   57    19        ASSIGN                                                   !1, $15
         20      > JMP                                                      ->30
   61    21    >   IN_ARRAY                                                 !2, <array>
         22      > JMPZ                                                     ~17, ->30
   62    23    >   INIT_FCALL                                               'array_map'
         24        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FodAKT%3A62%241'
         25        BIND_LEXICAL                                             ~18, !2
   64    26        SEND_VAL                                                 ~18
         27        SEND_VAR                                                 !0
         28        DO_ICALL                                         $19     
   62    29        ASSIGN                                                   !1, $19
   67    30    >   COUNT                                            ~21     !1
         31      > JMPZ                                                     ~21, ->46
   68    32    >   INIT_FCALL                                               'print_r'
         33        SEND_VAR                                                 !2
         34        DO_ICALL                                                 
   69    35        INIT_FCALL_BY_NAME                                       'ucword'
         36        SEND_VAR_EX                                              !2
         37        DO_FCALL                                      0  $23     
         38        CONCAT                                           ~24     'geoType', $23
         39        ASSIGN                                                   !3, ~24
   70    40        INIT_FCALL                                               'print_r'
         41        SEND_VAR                                                 !3
         42        DO_ICALL                                                 
   71    43        INIT_FCALL                                               'print_r'
         44        SEND_VAR                                                 !1
         45        DO_ICALL                                                 
   72    46    > > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FodAKT%3A57%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/odAKT
function name:  {closure}
number of ops:  7
compiled vars:  !0 = $geo
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   57     0  E >   RECV                                             !0      
   58     1        FETCH_DIM_R                                      ~1      !0, 'city'
          2        CONCAT                                           ~2      ~1, '%2C+'
          3        FETCH_DIM_R                                      ~3      !0, 'state'
          4        CONCAT                                           ~4      ~2, ~3
          5      > RETURN                                                   ~4
   59     6*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FodAKT%3A57%240

Function %00%7Bclosure%7D%2Fin%2FodAKT%3A62%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/odAKT
function name:  {closure}
number of ops:  8
compiled vars:  !0 = $geo, !1 = $geoTypeUppercase
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   62     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
   63     2        INIT_FCALL                                               'strtolower'
          3        SEND_VAR                                                 !1
          4        DO_ICALL                                         $2      
          5        FETCH_DIM_R                                      ~3      !0, $2
          6      > RETURN                                                   ~3
   64     7*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FodAKT%3A62%241

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
176 ms | 1400 KiB | 19 Q