3v4l.org

run code in 300+ PHP versions simultaneously
<?php function swap(string &$bankdata, string &$databasedata): void { // get the spaces from each word // we use preg_replace to remove additional spaces in any of the words. $bank_arr = explode(' ', preg_replace('/\s+/', ' ', $bankdata)); $data_arr = explode(' ' , preg_replace('/\s+/', ' ', $databasedata)); $bank_space_count = count($bank_arr); $data_space_count = count($data_arr); $fixUp = function (string $words, array $with) { $patterns = []; $replacements = []; foreach($with as $each_word) { // skip single characters if (strlen($each_word) == 1) { continue; } $patherns[] = "/{$each_word}/"; $replacements[] = "$0 "; } return preg_replace($patherns, $replacements, $words); }; if ($bank_space_count >= $data_space_count) { $databasedata = $fixUp($databasedata, $bank_arr); } else { $bankdata = $fixUp($bankdata, $data_arr); } } // $bankdata = 'DHANALAKSHMI K'; // $databasedata = 'DHANA LAXMI KOILADA'; // $bankdata = 'P VENKATESWARA RAO'; // $databasedata = 'PARELLA VENKATESWARARAO'; $bankdata = 'LINGAREDDY S'; $databasedata = 'LINGA REDDY SHEELAM'; swap($bankdata, $databasedata); var_dump($bankdata, $databasedata);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PBGGB
function name:  (null)
number of ops:  11
compiled vars:  !0 = $bankdata, !1 = $databasedata
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   47     0  E >   ASSIGN                                                   !0, 'LINGAREDDY+S'
   48     1        ASSIGN                                                   !1, 'LINGA+REDDY+SHEELAM'
   50     2        INIT_FCALL                                               'swap'
          3        SEND_REF                                                 !0
          4        SEND_REF                                                 !1
          5        DO_FCALL                                      0          
   54     6        INIT_FCALL                                               'var_dump'
          7        SEND_VAR                                                 !0
          8        SEND_VAR                                                 !1
          9        DO_ICALL                                                 
         10      > RETURN                                                   1

Function swap:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 30, Position 2 = 36
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 41
Branch analysis from position: 41
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 36
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PBGGB
function name:  swap
number of ops:  42
compiled vars:  !0 = $bankdata, !1 = $databasedata, !2 = $bank_arr, !3 = $data_arr, !4 = $bank_space_count, !5 = $data_space_count, !6 = $fixUp
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    7     2        INIT_FCALL                                               'explode'
          3        SEND_VAL                                                 '+'
          4        INIT_FCALL                                               'preg_replace'
          5        SEND_VAL                                                 '%2F%5Cs%2B%2F'
          6        SEND_VAL                                                 '+'
          7        SEND_VAR                                                 !0
          8        DO_ICALL                                         $7      
          9        SEND_VAR                                                 $7
         10        DO_ICALL                                         $8      
         11        ASSIGN                                                   !2, $8
    8    12        INIT_FCALL                                               'explode'
         13        SEND_VAL                                                 '+'
         14        INIT_FCALL                                               'preg_replace'
         15        SEND_VAL                                                 '%2F%5Cs%2B%2F'
         16        SEND_VAL                                                 '+'
         17        SEND_VAR                                                 !1
         18        DO_ICALL                                         $10     
         19        SEND_VAR                                                 $10
         20        DO_ICALL                                         $11     
         21        ASSIGN                                                   !3, $11
   10    22        COUNT                                            ~13     !2
         23        ASSIGN                                                   !4, ~13
   11    24        COUNT                                            ~15     !3
         25        ASSIGN                                                   !5, ~15
   13    26        DECLARE_LAMBDA_FUNCTION                          ~17     [0]
         27        ASSIGN                                                   !6, ~17
   31    28        IS_SMALLER_OR_EQUAL                                      !5, !4
         29      > JMPZ                                                     ~19, ->36
   32    30    >   INIT_DYNAMIC_CALL                                        !6
         31        SEND_VAR_EX                                              !1
         32        SEND_VAR_EX                                              !2
         33        DO_FCALL                                      0  $20     
         34        ASSIGN                                                   !1, $20
   31    35      > JMP                                                      ->41
   35    36    >   INIT_DYNAMIC_CALL                                        !6
         37        SEND_VAR_EX                                              !0
         38        SEND_VAR_EX                                              !3
         39        DO_FCALL                                      0  $22     
         40        ASSIGN                                                   !0, $22
   37    41    > > RETURN                                                   null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 18
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 18
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 10
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
filename:       /in/PBGGB
function name:  {closure}
number of ops:  26
compiled vars:  !0 = $words, !1 = $with, !2 = $patterns, !3 = $replacements, !4 = $each_word, !5 = $patherns
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   15     2        ASSIGN                                                   !2, <array>
   16     3        ASSIGN                                                   !3, <array>
   17     4      > FE_RESET_R                                       $8      !1, ->18
          5    > > FE_FETCH_R                                               $8, !4, ->18
   19     6    >   STRLEN                                           ~9      !4
          7        IS_EQUAL                                                 ~9, 1
          8      > JMPZ                                                     ~10, ->10
   20     9    > > JMP                                                      ->5
   23    10    >   ROPE_INIT                                     3  ~13     '%2F'
         11        ROPE_ADD                                      1  ~13     ~13, !4
         12        ROPE_END                                      2  ~12     ~13, '%2F'
         13        ASSIGN_DIM                                               !5
         14        OP_DATA                                                  ~12
   24    15        ASSIGN_DIM                                               !3
         16        OP_DATA                                                  '%240+'
   17    17      > JMP                                                      ->5
         18    >   FE_FREE                                                  $8
   27    19        INIT_FCALL                                               'preg_replace'
         20        SEND_VAR                                                 !5
         21        SEND_VAR                                                 !3
         22        SEND_VAR                                                 !0
         23        DO_ICALL                                         $16     
         24      > RETURN                                                   $16
   28    25*     > RETURN                                                   null

End of Dynamic Function 0

End of function swap

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
287.52 ms | 1024 KiB | 17 Q