3v4l.org

run code in 500+ 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 = 24, Position 2 = 30
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 35
Branch analysis from position: 35
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PBGGB
function name:  swap
number of ops:  36
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        FRAMELESS_ICALL_3                preg_replace        ~7      '%2F%5Cs%2B%2F', '+'
          5        OP_DATA                                                      !0
          6        SEND_VAL                                                     ~7
          7        DO_ICALL                                             $8      
          8        ASSIGN                                                       !2, $8
    8     9        INIT_FCALL                                                   'explode'
         10        SEND_VAL                                                     '+'
         11        FRAMELESS_ICALL_3                preg_replace        ~10     '%2F%5Cs%2B%2F', '+'
         12        OP_DATA                                                      !1
         13        SEND_VAL                                                     ~10
         14        DO_ICALL                                             $11     
         15        ASSIGN                                                       !3, $11
   10    16        COUNT                                                ~13     !2
         17        ASSIGN                                                       !4, ~13
   11    18        COUNT                                                ~15     !3
         19        ASSIGN                                                       !5, ~15
   13    20        DECLARE_LAMBDA_FUNCTION                              ~17     [0]
         21        ASSIGN                                                       !6, ~17
   31    22        IS_SMALLER_OR_EQUAL                                          !5, !4
         23      > JMPZ                                                         ~19, ->30
   32    24    >   INIT_DYNAMIC_CALL                                            !6
         25        SEND_VAR_EX                                                  !1
         26        SEND_VAR_EX                                                  !2
         27        DO_FCALL                                          0  $20     
         28        ASSIGN                                                       !1, $20
   31    29      > JMP                                                          ->35
   35    30    >   INIT_DYNAMIC_CALL                                            !6
         31        SEND_VAR_EX                                                  !0
         32        SEND_VAR_EX                                                  !3
         33        DO_FCALL                                          0  $22     
         34        ASSIGN                                                       !0, $22
   37    35    > > 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:swap():13}
number of ops:  23
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        FRAMELESS_ICALL_3                preg_replace        ~16     !5, !3
         20        OP_DATA                                                      !0
         21      > RETURN                                                       ~16
   28    22*     > RETURN                                                       null

End of Dynamic Function 0

End of function swap

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
223.41 ms | 2293 KiB | 16 Q