3v4l.org

run code in 300+ PHP versions simultaneously
<?php $strings = [ 'the(crow)bar', 'foo()bar', 'handlebar()', '()foofighters', '(foobar)', '()', 'barfood', 'barf(oo', 'fooeybar)', ')foob(', ]; function findFirstStringInBracket($str){ if(strlen($str) > 0){ $firstbracket = strstr($str, '('); if($firstbracket){ $firstbracket = ltrim($firstbracket, '('); return strstr($firstbracket, ')', true); }else{ return ''; } }else{ return ''; } } $result = []; foreach ($strings as $string) { $result[$string] = findFirstStringInBracket($string); } var_export($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 10
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 10
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
filename:       /in/CDeE0
function name:  (null)
number of ops:  15
compiled vars:  !0 = $strings, !1 = $result, !2 = $string
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   28     1        ASSIGN                                                   !1, <array>
   29     2      > FE_RESET_R                                       $5      !0, ->10
          3    > > FE_FETCH_R                                               $5, !2, ->10
   30     4    >   INIT_FCALL                                               'findfirststringinbracket'
          5        SEND_VAR                                                 !2
          6        DO_FCALL                                      0  $7      
          7        ASSIGN_DIM                                               !1, !2
          8        OP_DATA                                                  $7
   29     9      > JMP                                                      ->3
         10    >   FE_FREE                                                  $5
   32    11        INIT_FCALL                                               'var_export'
         12        SEND_VAR                                                 !1
         13        DO_ICALL                                                 
         14      > RETURN                                                   1

Function findfirststringinbracket:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 24
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 22
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/CDeE0
function name:  findFirstStringInBracket
number of ops:  26
compiled vars:  !0 = $str, !1 = $firstbracket
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   RECV                                             !0      
   16     1        STRLEN                                           ~2      !0
          2        IS_SMALLER                                               0, ~2
          3      > JMPZ                                                     ~3, ->24
   17     4    >   INIT_FCALL                                               'strstr'
          5        SEND_VAR                                                 !0
          6        SEND_VAL                                                 '%28'
          7        DO_ICALL                                         $4      
          8        ASSIGN                                                   !1, $4
   18     9      > JMPZ                                                     !1, ->22
   19    10    >   INIT_FCALL                                               'ltrim'
         11        SEND_VAR                                                 !1
         12        SEND_VAL                                                 '%28'
         13        DO_ICALL                                         $6      
         14        ASSIGN                                                   !1, $6
   20    15        INIT_FCALL                                               'strstr'
         16        SEND_VAR                                                 !1
         17        SEND_VAL                                                 '%29'
         18        SEND_VAL                                                 <true>
         19        DO_ICALL                                         $8      
         20      > RETURN                                                   $8
   18    21*       JMP                                                      ->23
   22    22    > > RETURN                                                   ''
   16    23*       JMP                                                      ->25
   25    24    > > RETURN                                                   ''
   27    25*     > RETURN                                                   null

End of function findfirststringinbracket

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
143.42 ms | 1011 KiB | 17 Q