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/a 2\\a52"B"/20 "O" (poznań-stare miasto)'; //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 slashu i backslashu oraz cudzysłowiu duża litera //$first_upper = preg_replace_callback('/([\/"\\\].)/ui', '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/ShPW1
function name:  (null)
number of ops:  55
compiled vars:  !0 = $address_l1, !1 = $first_upper
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   ASSIGN                                                   !0, 'Ul.+Tadeusza+Zawadzkiego%22zo%C5%9Bki%22+59%2F11%2Fa+2%5Ca52%22B%22%2F20+%22O%22+%28pozna%C5%84-stare+miasto%29'
   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        ASSIGN                                                   !1, $4
   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        ASSIGN                                                   !1, $6
   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        ASSIGN                                                   !1, $8
   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        ASSIGN                                                   !1, $10
   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        ASSIGN                                                   !1, $12
   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        ASSIGN                                                   !1, $15
   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        ASSIGN                                                   !1, $17
   37    47        INIT_FCALL                                               'trim'
         48        SEND_VAR                                                 !1
         49        DO_ICALL                                         $19     
         50        ASSIGN                                                   !1, $19
   39    51        INIT_FCALL                                               'var_dump'
         52        SEND_VAR                                                 !1
         53        DO_ICALL                                                 
         54      > RETURN                                                   1

Function arraytoupper:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ShPW1
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/ShPW1
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:
191.14 ms | 1392 KiB | 27 Q