3v4l.org

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

End of function %00%7Bclosure%7D%2Fin%2F9JiRC%3A58%240

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

End of function %00%7Bclosure%7D%2Fin%2F9JiRC%3A63%241

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
170.73 ms | 1400 KiB | 21 Q