3v4l.org

run code in 300+ PHP versions simultaneously
<?php function formatAds(array $ad): array { $ad['last_name'] = ucfirst($ad['last_name']); $ad['first_name'] = ucfirst($ad['first_name']); $phoneNumber = preg_replace(['/ /', '/^0?33/'], ['', '0'], $ad['phone_number']); $ad['phone_number'] = preg_match('/^0[1-9][\d]{8}$/', $phoneNumber, $matches) ? $matches[0] : null; return $ad; } $ad1 = [ "last_name" => "foo", "first_name" => "bar", "phone_number" => "04 55 66 77 11", ]; $ad2 = [ "last_name" => "flow", "first_name" => "blow", "phone_number" => "334 55 66 77 11", ]; $ad3 = [ "last_name" => "beez", "first_name" => "wiiz", "phone_number" => "0334 55 66 77 11", ]; print_r(formatAds($ad1)); print_r(formatAds($ad2)); print_r(formatAds($ad3));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PIX3X
function name:  (null)
number of ops:  22
compiled vars:  !0 = $ad1, !1 = $ad2, !2 = $ad3
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   ASSIGN                                                   !0, <array>
   21     1        ASSIGN                                                   !1, <array>
   27     2        ASSIGN                                                   !2, <array>
   33     3        INIT_FCALL                                               'print_r'
          4        INIT_FCALL                                               'formatads'
          5        SEND_VAR                                                 !0
          6        DO_FCALL                                      0  $6      
          7        SEND_VAR                                                 $6
          8        DO_ICALL                                                 
   34     9        INIT_FCALL                                               'print_r'
         10        INIT_FCALL                                               'formatads'
         11        SEND_VAR                                                 !1
         12        DO_FCALL                                      0  $8      
         13        SEND_VAR                                                 $8
         14        DO_ICALL                                                 
   35    15        INIT_FCALL                                               'print_r'
         16        INIT_FCALL                                               'formatads'
         17        SEND_VAR                                                 !2
         18        DO_FCALL                                      0  $10     
         19        SEND_VAR                                                 $10
         20        DO_ICALL                                                 
         21      > RETURN                                                   1

Function formatads:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 26, Position 2 = 29
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 30
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PIX3X
function name:  formatAds
number of ops:  36
compiled vars:  !0 = $ad, !1 = $phoneNumber, !2 = $matches
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    5     1        INIT_FCALL                                               'ucfirst'
          2        FETCH_DIM_R                                      ~4      !0, 'last_name'
          3        SEND_VAL                                                 ~4
          4        DO_ICALL                                         $5      
          5        ASSIGN_DIM                                               !0, 'last_name'
          6        OP_DATA                                                  $5
    6     7        INIT_FCALL                                               'ucfirst'
          8        FETCH_DIM_R                                      ~7      !0, 'first_name'
          9        SEND_VAL                                                 ~7
         10        DO_ICALL                                         $8      
         11        ASSIGN_DIM                                               !0, 'first_name'
         12        OP_DATA                                                  $8
    8    13        INIT_FCALL                                               'preg_replace'
         14        SEND_VAL                                                 <array>
         15        SEND_VAL                                                 <array>
         16        FETCH_DIM_R                                      ~9      !0, 'phone_number'
         17        SEND_VAL                                                 ~9
         18        DO_ICALL                                         $10     
         19        ASSIGN                                                   !1, $10
    9    20        INIT_FCALL                                               'preg_match'
         21        SEND_VAL                                                 '%2F%5E0%5B1-9%5D%5B%5Cd%5D%7B8%7D%24%2F'
         22        SEND_VAR                                                 !1
         23        SEND_REF                                                 !2
         24        DO_ICALL                                         $13     
         25      > JMPZ                                                     $13, ->29
         26    >   FETCH_DIM_R                                      ~14     !2, 0
         27        QM_ASSIGN                                        ~15     ~14
         28      > JMP                                                      ->30
         29    >   QM_ASSIGN                                        ~15     null
         30    >   ASSIGN_DIM                                               !0, 'phone_number'
         31        OP_DATA                                                  ~15
   11    32        VERIFY_RETURN_TYPE                                       !0
         33      > RETURN                                                   !0
   13    34*       VERIFY_RETURN_TYPE                                       
         35*     > RETURN                                                   null

End of function formatads

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
135.32 ms | 1010 KiB | 20 Q