3v4l.org

run code in 300+ PHP versions simultaneously
<?php mb_internal_encoding('UTF-8'); function get_goods_info($str) { $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('/', '色 ', ltrim(mb_substr($str, 0, $iro_pos + 1))); $ret['weight'] = ltrim(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/0eEMm
function name:  (null)
number of ops:  10
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'mb_internal_encoding'
          1        SEND_VAL                                                 'UTF-8'
          2        DO_ICALL                                                 
   20     3        INIT_FCALL                                               'var_dump'
   21     4        INIT_FCALL                                               'get_goods_info'
          5        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'
          6        DO_FCALL                                      0  $1      
          7        SEND_VAR                                                 $1
          8        DO_ICALL                                                 
   25     9      > RETURN                                                   1

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

End of function get_goods_info

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
159.68 ms | 1403 KiB | 30 Q