3v4l.org

run code in 300+ PHP versions simultaneously
<?php function capitalize_after_periods($string='', $delimiters = array()) { foreach ($delimiters as $delimiter) { $temp = explode($delimiter, $string); array_walk($temp, function (&$value) { $value = ucfirst($value); }); $string = implode($temp, $delimiter); } return $string; } $string ="I am a string with several periods.period #1. period #2."; $result = capitalize_after_periods($string, array('.', '. ')); var_dump($result);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/DMZ0t
function name:  (null)
number of ops:  10
compiled vars:  !0 = $string, !1 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   ASSIGN                                                   !0, 'I+am+a+string+with+several+periods.period+%231.+period+%232.'
   16     1        INIT_FCALL                                               'capitalize_after_periods'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 <array>
          4        DO_FCALL                                      0  $3      
          5        ASSIGN                                                   !1, $3
   18     6        INIT_FCALL                                               'var_dump'
          7        SEND_VAR                                                 !1
          8        DO_ICALL                                                 
          9      > RETURN                                                   1

Function capitalize_after_periods:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 20
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 20
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
filename:       /in/DMZ0t
function name:  capitalize_after_periods
number of ops:  23
compiled vars:  !0 = $string, !1 = $delimiters, !2 = $delimiter, !3 = $temp
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV_INIT                                        !0      ''
          1        RECV_INIT                                        !1      <array>
    5     2      > FE_RESET_R                                       $4      !1, ->20
          3    > > FE_FETCH_R                                               $4, !2, ->20
    7     4    >   INIT_FCALL                                               'explode'
          5        SEND_VAR                                                 !2
          6        SEND_VAR                                                 !0
          7        DO_ICALL                                         $5      
          8        ASSIGN                                                   !3, $5
    8     9        INIT_FCALL                                               'array_walk'
         10        SEND_REF                                                 !3
         11        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FDMZ0t%3A8%240'
         12        SEND_VAL                                                 ~7
         13        DO_ICALL                                                 
    9    14        INIT_FCALL                                               'implode'
         15        SEND_VAR                                                 !3
         16        SEND_VAR                                                 !2
         17        DO_ICALL                                         $9      
         18        ASSIGN                                                   !0, $9
    5    19      > JMP                                                      ->3
         20    >   FE_FREE                                                  $4
   11    21      > RETURN                                                   !0
   12    22*     > RETURN                                                   null

End of function capitalize_after_periods

Function %00%7Bclosure%7D%2Fin%2FDMZ0t%3A8%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/DMZ0t
function name:  {closure}
number of ops:  6
compiled vars:  !0 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
          1        INIT_FCALL                                               'ucfirst'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $1      
          4        ASSIGN                                                   !0, $1
          5      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FDMZ0t%3A8%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
166.86 ms | 1407 KiB | 24 Q