3v4l.org

run code in 300+ PHP versions simultaneously
<?php function get_goods_info($str) { mb_internal_encoding('UTF-8'); $ret = array(); if (($sharp_pos = strpos($str, '#')) === false) { return false; } $ret['description'] = substr($str, 0, $sharp_pos); $str = substr($str, $sharp_pos + 1); if (($iro_pos = mb_strpos($str, '色')) === false) { return false; } $ret['color'] = str_replace('/', '色 ', mb_substr($str, 0, $iro_pos + 1)); $ret['weight'] = mb_substr($str, $iro_pos + 1); return $ret; } var_dump( get_goods_info('光の3原色から選べます# 赤/青/黄色 210g') /* get_goods_info('# 茶/カーキ/黄/緑色 100g'), get_goods_info('1色でもOK・なんとなくkgにも対応# 肌色 2.5kg'), get_goods_info('これには# マッチしません ')*/ );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/72OeQ
function name:  (null)
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   INIT_FCALL                                               'var_dump'
   20     1        INIT_FCALL                                               'get_goods_info'
          2        SEND_VAL                                                 '%E5%85%89%E3%81%AE3%E5%8E%9F%E8%89%B2%E3%81%8B%E3%82%89%E9%81%B8%E3%81%B9%E3%81%BE%E3%81%99%23+++++%E8%B5%A4%2F%E9%9D%92%2F%E9%BB%84%E8%89%B2++210g'
          3        DO_FCALL                                      0  $0      
          4        SEND_VAR                                                 $0
          5        DO_ICALL                                                 
   24     6      > RETURN                                                   1

Function get_goods_info:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 13
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 33, Position 2 = 34
Branch analysis from position: 33
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 34
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/72OeQ
function name:  get_goods_info
number of ops:  56
compiled vars:  !0 = $str, !1 = $ret, !2 = $sharp_pos, !3 = $iro_pos
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        INIT_FCALL                                               'mb_internal_encoding'
          2        SEND_VAL                                                 'UTF-8'
          3        DO_ICALL                                                 
    5     4        ASSIGN                                                   !1, <array>
    6     5        INIT_FCALL                                               'strpos'
          6        SEND_VAR                                                 !0
          7        SEND_VAL                                                 '%23'
          8        DO_ICALL                                         $6      
          9        ASSIGN                                           ~7      !2, $6
         10        TYPE_CHECK                                    4          ~7
         11      > JMPZ                                                     ~8, ->13
    7    12    > > RETURN                                                   <false>
    9    13    >   INIT_FCALL                                               'substr'
         14        SEND_VAR                                                 !0
         15        SEND_VAL                                                 0
         16        SEND_VAR                                                 !2
         17        DO_ICALL                                         $10     
         18        ASSIGN_DIM                                               !1, 'description'
         19        OP_DATA                                                  $10
   10    20        INIT_FCALL                                               'substr'
         21        SEND_VAR                                                 !0
         22        ADD                                              ~11     !2, 1
         23        SEND_VAL                                                 ~11
         24        DO_ICALL                                         $12     
         25        ASSIGN                                                   !0, $12
   11    26        INIT_FCALL                                               'mb_strpos'
         27        SEND_VAR                                                 !0
         28        SEND_VAL                                                 '%E8%89%B2'
         29        DO_ICALL                                         $14     
         30        ASSIGN                                           ~15     !3, $14
         31        TYPE_CHECK                                    4          ~15
         32      > JMPZ                                                     ~16, ->34
   12    33    > > RETURN                                                   <false>
   14    34    >   INIT_FCALL                                               'str_replace'
         35        SEND_VAL                                                 '%2F'
         36        SEND_VAL                                                 '%E8%89%B2+'
         37        INIT_FCALL                                               'mb_substr'
         38        SEND_VAR                                                 !0
         39        SEND_VAL                                                 0
         40        ADD                                              ~18     !3, 1
         41        SEND_VAL                                                 ~18
         42        DO_ICALL                                         $19     
         43        SEND_VAR                                                 $19
         44        DO_ICALL                                         $20     
         45        ASSIGN_DIM                                               !1, 'color'
         46        OP_DATA                                                  $20
   15    47        INIT_FCALL                                               'mb_substr'
         48        SEND_VAR                                                 !0
         49        ADD                                              ~22     !3, 1
         50        SEND_VAL                                                 ~22
         51        DO_ICALL                                         $23     
         52        ASSIGN_DIM                                               !1, 'weight'
         53        OP_DATA                                                  $23
   16    54      > RETURN                                                   !1
   17    55*     > RETURN                                                   null

End of function get_goods_info

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
168.78 ms | 1394 KiB | 28 Q