3v4l.org

run code in 300+ PHP versions simultaneously
<?php function escape_possible($chaines, $sepChmp, $dlmtTxt) { $escape_possible = []; if( preg_match_all("#((?<![$dlmtTxt])$dlmtTxt(?!$dlmtTxt)).*?(?1)#su", $chaines, $encadres) ) { foreach( $encadres[0] as $encadre) { if( preg_match_all("#.(?=$sepChmp)#su", $encadre, $escapes) ) { foreach($escapes[0] as $escape) { if(isset($escape_possible[$escape])) $escape_possible[$escape]++; else $escape_possible[$escape] = 1; } } } } arsort($escape_possible); return $escape_possible; } // cas 1 $sepChmp = ';'; $dlmtTxt = '"'; $chaines = '"il a dit ""aie"" ; en criant" "Laurent TOGIER";"19\; Rue Bréa";75006;PARIS Laurent TOGIER;"\; Rue Bréa";75006;PARIS Laurent TOGIER;"19\;";75006;PARIS Laurent TOGIER;"\;";75006;PARIS Laurent TOGIER;"19\; Rue\; Bréa";75006;PARIS Laurent TOGIER;"\;\;";75006;PARIS'; var_dump(escape_possible($chaines, $sepChmp, $dlmtTxt)); /* array(2) { ["\"]=> int(8) [" "]=> int(1) } */ // cas 2 $sepChmp = '§'; // utf-8 $dlmtTxt = '`'; $chaines = '`Laurent TOGIER`§`19/§ Rue Bréa`§75006§PARIS Laurent TOGIER§`/§ Rue Bréa`§75006§PARIS Laurent TOGIER§`19/§`§75006§PARIS Laurent TOGIER§`/§`§75006§PARIS Laurent TOGIER§`19/§ Rue/§ Bréa`§75006§PARIS Laurent TOGIER§`/§/§`§75006§PARIS `il a dit ``aie`` § en criant`'; var_dump(escape_possible($chaines, $sepChmp, $dlmtTxt)); /* array(2) { ["/"]=> int(8) [" "]=> int(1) } */
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4jInS
function name:  (null)
number of ops:  23
compiled vars:  !0 = $sepChmp, !1 = $dlmtTxt, !2 = $chaines
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   ASSIGN                                                   !0, '%3B'
   22     1        ASSIGN                                                   !1, '%22'
   23     2        ASSIGN                                                   !2, '%22il+a+dit+%22%22aie%22%22+%3B+en+criant%22%0A%22Laurent+TOGIER%22%3B%2219%5C%3B+Rue+Br%C3%A9a%22%3B75006%3BPARIS%0ALaurent+TOGIER%3B%22%5C%3B+Rue+Br%C3%A9a%22%3B75006%3BPARIS%0ALaurent+TOGIER%3B%2219%5C%3B%22%3B75006%3BPARIS%0ALaurent+TOGIER%3B%22%5C%3B%22%3B75006%3BPARIS%0ALaurent+TOGIER%3B%2219%5C%3B+Rue%5C%3B+Br%C3%A9a%22%3B75006%3BPARIS%0ALaurent+TOGIER%3B%22%5C%3B%5C%3B%22%3B75006%3BPARIS'
   30     3        INIT_FCALL                                               'var_dump'
          4        INIT_FCALL                                               'escape_possible'
          5        SEND_VAR                                                 !2
          6        SEND_VAR                                                 !0
          7        SEND_VAR                                                 !1
          8        DO_FCALL                                      0  $6      
          9        SEND_VAR                                                 $6
         10        DO_ICALL                                                 
   42    11        ASSIGN                                                   !0, '%C2%A7'
   43    12        ASSIGN                                                   !1, '%60'
   44    13        ASSIGN                                                   !2, '%60Laurent+TOGIER%60%C2%A7%6019%2F%C2%A7+Rue+Br%C3%A9a%60%C2%A775006%C2%A7PARIS%0ALaurent+TOGIER%C2%A7%60%2F%C2%A7+Rue+Br%C3%A9a%60%C2%A775006%C2%A7PARIS%0ALaurent+TOGIER%C2%A7%6019%2F%C2%A7%60%C2%A775006%C2%A7PARIS%0ALaurent+TOGIER%C2%A7%60%2F%C2%A7%60%C2%A775006%C2%A7PARIS%0ALaurent+TOGIER%C2%A7%6019%2F%C2%A7+Rue%2F%C2%A7+Br%C3%A9a%60%C2%A775006%C2%A7PARIS%0ALaurent+TOGIER%C2%A7%60%2F%C2%A7%2F%C2%A7%60%C2%A775006%C2%A7PARIS%0A%60il+a+dit+%60%60aie%60%60+%C2%A7+en+criant%60'
   51    14        INIT_FCALL                                               'var_dump'
         15        INIT_FCALL                                               'escape_possible'
         16        SEND_VAR                                                 !2
         17        SEND_VAR                                                 !0
         18        SEND_VAR                                                 !1
         19        DO_FCALL                                      0  $11     
         20        SEND_VAR                                                 $11
         21        DO_ICALL                                                 
   59    22      > RETURN                                                   1

Function escape_possible:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 43
Branch analysis from position: 17
2 jumps found. (Code = 77) Position 1 = 19, Position 2 = 42
Branch analysis from position: 19
2 jumps found. (Code = 78) Position 1 = 20, Position 2 = 42
Branch analysis from position: 20
2 jumps found. (Code = 43) Position 1 = 29, Position 2 = 41
Branch analysis from position: 29
2 jumps found. (Code = 77) Position 1 = 31, Position 2 = 40
Branch analysis from position: 31
2 jumps found. (Code = 78) Position 1 = 32, Position 2 = 40
Branch analysis from position: 32
2 jumps found. (Code = 43) Position 1 = 34, Position 2 = 37
Branch analysis from position: 34
1 jumps found. (Code = 42) Position 1 = 39
Branch analysis from position: 39
1 jumps found. (Code = 42) Position 1 = 31
Branch analysis from position: 31
Branch analysis from position: 37
1 jumps found. (Code = 42) Position 1 = 31
Branch analysis from position: 31
Branch analysis from position: 40
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
Branch analysis from position: 40
Branch analysis from position: 41
Branch analysis from position: 42
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 42
Branch analysis from position: 43
filename:       /in/4jInS
function name:  escape_possible
number of ops:  48
compiled vars:  !0 = $chaines, !1 = $sepChmp, !2 = $dlmtTxt, !3 = $escape_possible, !4 = $encadres, !5 = $encadre, !6 = $escapes, !7 = $escape
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
    5     3        ASSIGN                                                   !3, <array>
    6     4        INIT_FCALL                                               'preg_match_all'
          5        ROPE_INIT                                     7  ~10     '%23%28%28%3F%3C%21%5B'
          6        ROPE_ADD                                      1  ~10     ~10, !2
          7        ROPE_ADD                                      2  ~10     ~10, '%5D%29'
          8        ROPE_ADD                                      3  ~10     ~10, !2
          9        ROPE_ADD                                      4  ~10     ~10, '%28%3F%21'
         10        ROPE_ADD                                      5  ~10     ~10, !2
         11        ROPE_END                                      6  ~9      ~10, '%29%29.%2A%3F%28%3F1%29%23su'
         12        SEND_VAL                                                 ~9
         13        SEND_VAR                                                 !0
         14        SEND_REF                                                 !4
         15        DO_ICALL                                         $14     
         16      > JMPZ                                                     $14, ->43
    7    17    >   FETCH_DIM_R                                      ~15     !4, 0
         18      > FE_RESET_R                                       $16     ~15, ->42
         19    > > FE_FETCH_R                                               $16, !5, ->42
    8    20    >   INIT_FCALL                                               'preg_match_all'
         21        ROPE_INIT                                     3  ~18     '%23.%28%3F%3D'
         22        ROPE_ADD                                      1  ~18     ~18, !1
         23        ROPE_END                                      2  ~17     ~18, '%29%23su'
         24        SEND_VAL                                                 ~17
         25        SEND_VAR                                                 !5
         26        SEND_REF                                                 !6
         27        DO_ICALL                                         $20     
         28      > JMPZ                                                     $20, ->41
    9    29    >   FETCH_DIM_R                                      ~21     !6, 0
         30      > FE_RESET_R                                       $22     ~21, ->40
         31    > > FE_FETCH_R                                               $22, !7, ->40
   10    32    >   ISSET_ISEMPTY_DIM_OBJ                         0          !3, !7
         33      > JMPZ                                                     ~23, ->37
         34    >   FETCH_DIM_RW                                     $24     !3, !7
         35        PRE_INC                                                  $24
         36      > JMP                                                      ->39
   11    37    >   ASSIGN_DIM                                               !3, !7
         38        OP_DATA                                                  1
    9    39    > > JMP                                                      ->31
         40    >   FE_FREE                                                  $22
    7    41    > > JMP                                                      ->19
         42    >   FE_FREE                                                  $16
   16    43    >   INIT_FCALL                                               'arsort'
         44        SEND_REF                                                 !3
         45        DO_ICALL                                                 
   17    46      > RETURN                                                   !3
   18    47*     > RETURN                                                   null

End of function escape_possible

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
163.91 ms | 1411 KiB | 21 Q