3v4l.org

run code in 300+ PHP versions simultaneously
<?php function arrayToUpper($array) { return mb_strtoupper($array[0], 'UTF-8'); } function arrayToLower($array) { return mb_strtolower($array[0], 'UTF-8'); } $address_l1 = 'Ul. Tadeusza Zawadzkiego "zośki" 59/11'; //zamieniamy znaki specjalne (tabulator, enter) na spację $first_upper = preg_replace('/([\n\r\t])/ui', ' ', trim($address_l1)); //ciąg więcej niż jedna spacja zamieniamy na jedną spację $first_upper = preg_replace('/([ ]{2,})/ui', ' ', $first_upper); //wycinamy spacje po kropkach... $first_upper = preg_replace('/(\.[ ]+)/ui', '.', $first_upper); //i wstawiamy po kropce zawsze jedną spację $first_upper = preg_replace('/(\.)/ui', '. ', $first_upper); //pierwsze litery wielkie $first_upper = mb_convert_case($first_upper, MB_CASE_TITLE, 'UTF-8'); //liczby rzymskie muszą być wszystkie wielkimi (bierzemy tylko pod uwagę liczby ze znakami I, V, X) $first_upper = preg_replace_callback('/([ \.]+[IVX-]{2,})/ui', 'arrayToUpper', " ".$first_upper); //po apostrofie mała litera $first_upper = preg_replace_callback('/([\'`].)/ui', 'arrayToLower', $first_upper); //po ukośniku duża litera litera $first_upper = preg_replace_callback('/([\/].)/ui', array(&$this, 'arrayToUpper'), $first_upper); //obcinamy spacje na początku i końcu $first_upper = trim($first_upper); var_dump($first_upper);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/d9303
function name:  (null)
number of ops:  64
compiled vars:  !0 = $address_l1, !1 = $first_upper
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  10     0  E >   QM_ASSIGN                                                !0
  13     1        INIT_FCALL                                               'preg_replace'
         2        SEND_VAL                                                 '%2F%28%5B%5Cn%5Cr%5Ct%5D%29%2Fui'
         3        SEND_VAL                                                 '+'
         4        INIT_FCALL                                               'trim'
         5        SEND_VAR                                                 !0
         6        DO_ICALL                                         $3      
         7        SEND_VAR                                                 $3
         8        DO_ICALL                                         $4      
         9        QM_ASSIGN                                                !1
  16    10        INIT_FCALL                                               'preg_replace'
        11        SEND_VAL                                                 '%2F%28%5B+%5D%7B2%2C%7D%29%2Fui'
        12        SEND_VAL                                                 '+'
        13        SEND_VAR                                                 !1
        14        DO_ICALL                                         $6      
        15        QM_ASSIGN                                                !1
  19    16        INIT_FCALL                                               'preg_replace'
        17        SEND_VAL                                                 '%2F%28%5C.%5B+%5D%2B%29%2Fui'
        18        SEND_VAL                                                 '.'
        19        SEND_VAR                                                 !1
        20        DO_ICALL                                         $8      
        21        QM_ASSIGN                                                !1
  22    22        INIT_FCALL                                               'preg_replace'
        23        SEND_VAL                                                 '%2F%28%5C.%29%2Fui'
        24        SEND_VAL                                                 '.+'
        25        SEND_VAR                                                 !1
        26        DO_ICALL                                         $10     
        27        QM_ASSIGN                                                !1
  25    28        INIT_FCALL                                               'mb_convert_case'
        29        SEND_VAR                                                 !1
        30        SEND_VAL                                                 2
        31        SEND_VAL                                                 'UTF-8'
        32        DO_ICALL                                         $12     
        33        QM_ASSIGN                                                !1
  28    34        INIT_FCALL                                               'preg_replace_callback'
        35        SEND_VAL                                                 '%2F%28%5B+%5C.%5D%2B%5BIVX-%5D%7B2%2C%7D%29%2Fui'
        36        SEND_VAL                                                 'arrayToUpper'
        37        CONCAT                                           ~14     '+', !1
        38        SEND_VAL                                                 ~14
        39        DO_ICALL                                         $15     
        40        QM_ASSIGN                                                !1
  31    41        INIT_FCALL                                               'preg_replace_callback'
        42        SEND_VAL                                                 '%2F%28%5B%27%60%5D.%29%2Fui'
        43        SEND_VAL                                                 'arrayToLower'
        44        SEND_VAR                                                 !1
        45        DO_ICALL                                         $17     
        46        QM_ASSIGN                                                !1
  34    47        INIT_FCALL                                               'preg_replace_callback'
        48        SEND_VAL                                                 '%2F%28%5B%5C%2F%5D.%29%2Fui'
        49        FETCH_THIS                                       $19     
        50        INIT_ARRAY                                       ~20     $19
        51        ADD_ARRAY_ELEMENT                                ~20     'arrayToUpper'
        52        SEND_VAL                                                 ~20
        53        SEND_VAR                                                 !1
        54        DO_ICALL                                         $21     
        55        QM_ASSIGN                                                !1
  38    56        INIT_FCALL                                               'trim'
        57        SEND_VAR                                                 !1
        58        DO_ICALL                                         $23     
        59        QM_ASSIGN                                                !1
  40    60        INIT_FCALL                                               'var_dump'
        61        SEND_VAR                                                 !1
        62        DO_ICALL                                                 
        63      > RETURN                                                   1

Function arraytoupper:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/d9303
function name:  arrayToUpper
number of ops:  8
compiled vars:  !0 = $array
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   2     0  E >   RECV                                             !0      
   3     1        INIT_FCALL                                               'mb_strtoupper'
         2        FETCH_DIM_R                                      ~1      !0, 0
         3        SEND_VAL                                                 ~1
         4        SEND_VAL                                                 'UTF-8'
         5        DO_ICALL                                         $2      
         6      > RETURN                                                   $2
   4     7*     > RETURN                                                   null

End of function arraytoupper

Function arraytolower:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/d9303
function name:  arrayToLower
number of ops:  8
compiled vars:  !0 = $array
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   6     0  E >   RECV                                             !0      
   7     1        INIT_FCALL                                               'mb_strtolower'
         2        FETCH_DIM_R                                      ~1      !0, 0
         3        SEND_VAL                                                 ~1
         4        SEND_VAL                                                 'UTF-8'
         5        DO_ICALL                                         $2      
         6      > RETURN                                                   $2
   8     7*     > RETURN                                                   null

End of function arraytolower

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
14.18 ms | 416 KiB | 7 Q