3v4l.org

run code in 300+ PHP versions simultaneously
<?php function upperCaseString($string) { $pattern = '/(?=\d)/'; $array = preg_split($pattern, $string, 2); $text=''; if(count($array)>1) { $text=ucwords(strtolower($array[0])).' '.strtoupper($array[1]); } else { $text=ucwords(strtolower($array[0])); } return $text; } $str = "NEW APPLE IPHONE X 64GB CVX-Dk46"; echo upperCaseString($str); ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jW6Wf
function name:  (null)
number of ops:  6
compiled vars:  !0 = $str
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   ASSIGN                                                   !0, 'NEW+APPLE+IPHONE+X+64GB+CVX-Dk46'
   19     1        INIT_FCALL                                               'uppercasestring'
          2        SEND_VAR                                                 !0
          3        DO_FCALL                                      0  $2      
          4        ECHO                                                     $2
   20     5      > RETURN                                                   1

Function uppercasestring:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 27
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 35
Branch analysis from position: 35
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jW6Wf
function name:  upperCaseString
number of ops:  37
compiled vars:  !0 = $string, !1 = $pattern, !2 = $array, !3 = $text
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    4     1        ASSIGN                                                   !1, '%2F%28%3F%3D%5Cd%29%2F'
    5     2        INIT_FCALL                                               'preg_split'
          3        SEND_VAR                                                 !1
          4        SEND_VAR                                                 !0
          5        SEND_VAL                                                 2
          6        DO_ICALL                                         $5      
          7        ASSIGN                                                   !2, $5
    6     8        ASSIGN                                                   !3, ''
    7     9        COUNT                                            ~8      !2
         10        IS_SMALLER                                               1, ~8
         11      > JMPZ                                                     ~9, ->27
   10    12    >   INIT_FCALL                                               'ucwords'
         13        INIT_FCALL                                               'strtolower'
         14        FETCH_DIM_R                                      ~10     !2, 0
         15        SEND_VAL                                                 ~10
         16        DO_ICALL                                         $11     
         17        SEND_VAR                                                 $11
         18        DO_ICALL                                         $12     
         19        CONCAT                                           ~13     $12, '+'
         20        INIT_FCALL                                               'strtoupper'
         21        FETCH_DIM_R                                      ~14     !2, 1
         22        SEND_VAL                                                 ~14
         23        DO_ICALL                                         $15     
         24        CONCAT                                           ~16     ~13, $15
         25        ASSIGN                                                   !3, ~16
    7    26      > JMP                                                      ->35
   14    27    >   INIT_FCALL                                               'ucwords'
         28        INIT_FCALL                                               'strtolower'
         29        FETCH_DIM_R                                      ~18     !2, 0
         30        SEND_VAL                                                 ~18
         31        DO_ICALL                                         $19     
         32        SEND_VAR                                                 $19
         33        DO_ICALL                                         $20     
         34        ASSIGN                                                   !3, $20
   16    35    > > RETURN                                                   !3
   17    36*     > RETURN                                                   null

End of function uppercasestring

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
138.55 ms | 1008 KiB | 18 Q