3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str1 = "CN=CMPPDepartemental_Secretariat,OU=1 - Groupes de sécurité,OU=CMPP,OU=Pole,OU=Utilisateurs,DC=ricky,DC=fr"; $str2 = "CN=CMPPDepartemental_Direction,OU=1 - Groupes de sécurité,OU=CMPP,OU=Pole,OU=Utilisateurs,DC=ricky,DC=fr"; var_dump(find_by_keyword($str2, "CN=")); function find_by_keyword( $string, $keyword ) { $array = explode(",",$string); $found = []; // Loop through each item and check for a match. foreach ( $array as $string ) { // If found somewhere inside the string, add. if ( strpos( $string, $keyword ) !== false ) { $found[] = substr($string, strlen($keyword)); } } return $found; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qA6MU
function name:  (null)
number of ops:  10
compiled vars:  !0 = $str1, !1 = $str2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, 'CN%3DCMPPDepartemental_Secretariat%2COU%3D1+-+Groupes+de+s%C3%A9curit%C3%A9%2COU%3DCMPP%2COU%3DPole%2COU%3DUtilisateurs%2CDC%3Dricky%2CDC%3Dfr'
    3     1        ASSIGN                                                   !1, 'CN%3DCMPPDepartemental_Direction%2COU%3D1+-+Groupes+de+s%C3%A9curit%C3%A9%2COU%3DCMPP%2COU%3DPole%2COU%3DUtilisateurs%2CDC%3Dricky%2CDC%3Dfr'
    5     2        INIT_FCALL                                               'var_dump'
          3        INIT_FCALL_BY_NAME                                       'find_by_keyword'
          4        SEND_VAR_EX                                              !1
          5        SEND_VAL_EX                                              'CN%3D'
          6        DO_FCALL                                      0  $4      
          7        SEND_VAR                                                 $4
          8        DO_ICALL                                                 
   18     9      > RETURN                                                   1

Function find_by_keyword:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 24
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 24
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 23
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 23
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
filename:       /in/qA6MU
function name:  find_by_keyword
number of ops:  27
compiled vars:  !0 = $string, !1 = $keyword, !2 = $array, !3 = $found
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    8     2        INIT_FCALL                                               'explode'
          3        SEND_VAL                                                 '%2C'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $4      
          6        ASSIGN                                                   !2, $4
    9     7        ASSIGN                                                   !3, <array>
   11     8      > FE_RESET_R                                       $7      !2, ->24
          9    > > FE_FETCH_R                                               $7, !0, ->24
   13    10    >   INIT_FCALL                                               'strpos'
         11        SEND_VAR                                                 !0
         12        SEND_VAR                                                 !1
         13        DO_ICALL                                         $8      
         14        TYPE_CHECK                                  1018          $8
         15      > JMPZ                                                     ~9, ->23
   14    16    >   INIT_FCALL                                               'substr'
         17        SEND_VAR                                                 !0
         18        STRLEN                                           ~11     !1
         19        SEND_VAL                                                 ~11
         20        DO_ICALL                                         $12     
         21        ASSIGN_DIM                                               !3
         22        OP_DATA                                                  $12
   11    23    > > JMP                                                      ->9
         24    >   FE_FREE                                                  $7
   17    25      > RETURN                                                   !3
   18    26*     > RETURN                                                   null

End of function find_by_keyword

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
209.24 ms | 1008 KiB | 17 Q