3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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
Jump found. Position 1 = -2
filename:       /in/d9303
function name:  (null)
number of ops:  65
compiled vars:  !0 = $address_l1, !1 = $first_upper, !2 = $this
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   2     0  E >   NOP                                                      
   6     1        NOP                                                      
  10     2        ASSIGN                                                   !0, 'Ul.+Tadeusza+Zawadzkiego+%22zo%C5%9Bki%22+59%2F11'
  13     3        INIT_FCALL                                               'preg_replace'
         4        SEND_VAL                                                 '%2F%28%5B%5Cn%5Cr%5Ct%5D%29%2Fui'
         5        SEND_VAL                                                 '+'
         6        INIT_FCALL                                               'trim'
         7        SEND_VAR                                                 !0
         8        DO_ICALL                                         $4      
         9        SEND_VAR                                                 $4
        10        DO_ICALL                                         $5      
        11        ASSIGN                                                   !1, $5
  16    12        INIT_FCALL                                               'preg_replace'
        13        SEND_VAL                                                 '%2F%28%5B+%5D%7B2%2C%7D%29%2Fui'
        14        SEND_VAL                                                 '+'
        15        SEND_VAR                                                 !1
        16        DO_ICALL                                         $7      
        17        ASSIGN                                                   !1, $7
  19    18        INIT_FCALL                                               'preg_replace'
        19        SEND_VAL                                                 '%2F%28%5C.%5B+%5D%2B%29%2Fui'
        20        SEND_VAL                                                 '.'
        21        SEND_VAR                                                 !1
        22        DO_ICALL                                         $9      
        23        ASSIGN                                                   !1, $9
  22    24        INIT_FCALL                                               'preg_replace'
        25        SEND_VAL                                                 '%2F%28%5C.%29%2Fui'
        26        SEND_VAL                                                 '.+'
        27        SEND_VAR                                                 !1
        28        DO_ICALL                                         $11     
        29        ASSIGN                                                   !1, $11
  25    30        INIT_FCALL                                               'mb_convert_case'
        31        SEND_VAR                                                 !1
        32        SEND_VAL                                                 2
        33        SEND_VAL                                                 'UTF-8'
        34        DO_ICALL                                         $13     
        35        ASSIGN                                                   !1, $13
  28    36        INIT_FCALL                                               'preg_replace_callback'
        37        SEND_VAL                                                 '%2F%28%5B+%5C.%5D%2B%5BIVX-%5D%7B2%2C%7D%29%2Fui'
        38        SEND_VAL                                                 'arrayToUpper'
        39        CONCAT                                           ~15     '+', !1
        40        SEND_VAL                                                 ~15
        41        DO_ICALL                                         $16     
        42        ASSIGN                                                   !1, $16
  31    43        INIT_FCALL                                               'preg_replace_callback'
        44        SEND_VAL                                                 '%2F%28%5B%27%60%5D.%29%2Fui'
        45        SEND_VAL                                                 'arrayToLower'
        46        SEND_VAR                                                 !1
        47        DO_ICALL                                         $18     
        48        ASSIGN                                                   !1, $18
  34    49        INIT_FCALL                                               'preg_replace_callback'
        50        SEND_VAL                                                 '%2F%28%5B%5C%2F%5D.%29%2Fui'
        51        INIT_ARRAY                                       ~20     !2
        52        ADD_ARRAY_ELEMENT                                ~20     'arrayToUpper'
        53        SEND_VAL                                                 ~20
        54        SEND_VAR                                                 !1
        55        DO_ICALL                                         $21     
        56        ASSIGN                                                   !1, $21
  38    57        INIT_FCALL                                               'trim'
        58        SEND_VAR                                                 !1
        59        DO_ICALL                                         $23     
        60        ASSIGN                                                   !1, $23
  40    61        INIT_FCALL                                               'var_dump'
        62        SEND_VAR                                                 !1
        63        DO_ICALL                                                 
        64      > RETURN                                                   1

Function arraytoupper:
Finding entry points
Branch analysis from position: 0
Jump found. 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_VAR                                                 $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
Jump found. 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_VAR                                                 $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 7.2.0