3v4l.org

run code in 300+ PHP versions simultaneously
<?php $args = []; $key = 'subFunction'; $value = 'Administratif,Asset Management,CTO,Administratif,Asset Management,CTO,Administratif,Asset Management,CTO'; //$listName = $this->parserDOM[$key][4]; //echo 'listName =>> ' . $listName . PHP_EOL; //// Retrieve the list and store it in an array //if ($listName) { // $list = []; // $qry = wh_get_select_qry('contents_lists', array('list' => $listName)); // $qry = str_replace('*', '`id_unique`, `title_1`', $qry); // $res = $this->sqli->query($qry); // while ($row = $res->fetch_assoc()) { // $list[$row['id_unique']] = $row['title_1']; // } //} $list = [ 'achats' => 'Achats', 'administratif' => 'Administratif', 'asset-management' => 'Asset Management', 'audit' => 'Audit', 'comptabilite' => 'Comptabilité', 'controle-de-gestion' => 'Contrôle de Gestion', 'crm' => 'CRM', 'daf' => 'DAF', 'data' => 'Data', 'dev-commercial' => 'Dév commercial', 'digital' => 'Digital', 'erp' => 'ERP', 'expertise-comptable' => 'Expertise comptable', 'formation' => 'Formation', 'gestion-multisite' => 'Gestion multisite', 'gestion-projets' => 'Gestion projets', 'immobilier' => 'Immobilier', 'it' => 'IT', 'juridique' => 'Juridique', 'logistique' => 'Logistique', 'mandat-ad-hoc-conciliation' => 'Mandat ad-hoc / conciliation', 'marque' => 'Marque', 'media' => 'Média', 'mep-process' => 'MEP process', 'offre' => 'Offre', 'omnicanal' => 'Omnicanal', 'outil-si' => 'Outil SI', 'paie' => 'Paie', 'production' => 'Production', 'produits-offre' => 'Produits - offre', 'projet' => 'Projet', 'qualite' => 'Qualité', 'rel-sociales' => 'Relations Sociales', 'rh' => 'RH', 'rse' => 'RSE', 'sirh' => 'SIRH', 'supply-chain' => 'Supply chain', 'transformation' => 'Transformation', 'tresorerie' => 'Trésorerie', 'cto' => 'CTO', 'cpo' => 'CPO', 'cdo' => 'CDO', ]; //print_r($list); //echo PHP_EOL; // Check the matching between arg value and list value if ($list) { $multiselectValues = explode(',', $value); // echo 'multiselectValues =>>'; // print_r($multiselectValues); // echo PHP_EOL; foreach ($multiselectValues as $valueKey => $multiselectValue) { $multiselectKeyFromValue = wh_clean_string_from_special_chars($multiselectValue); // echo '$multiselectKeyFromValue =>>'; // print_r($multiselectKeyFromValue); // echo PHP_EOL; // echo '$multiselectValue =>>'; // print_r($multiselectValue); // echo PHP_EOL; // echo 'in_array =>>'; // print_r(in_array($multiselectKeyFromValue, array_keys($list))); // echo PHP_EOL; // echo 'array_search =>>'; // print_r(array_search($multiselectValue, $list)); // echo PHP_EOL; if (in_array($multiselectKeyFromValue, array_keys($list)) || $multiselectKey = array_search( $multiselectValue, $list )) { echo '$multiselectKey =>>'; print_r($multiselectKey); echo PHP_EOL; $multiselectValues[] = $multiselectKey ?? $multiselectKeyFromValue;; echo '$multiselectValues add =>>'; print_r($multiselectValues); echo PHP_EOL; unset($multiselectValues[$valueKey]); unset($multiselectKey); echo '$multiselectValues unset =>>'; print_r($multiselectValues); echo PHP_EOL; // If there is no match with list key or value, include the custom list if the file exist } elseif (!array_key_exists($multiselectValue, $list)) { echo 'multiselectValue elseif =>>' . $multiselectValue; echo PHP_EOL; } } } $args[$key] = json_encode($multiselectValues); print_r($args); echo PHP_EOL; /** * The wh_clean_string_from_special_chars function will clean a string replacing the special character by the character passed in parameter. * * It will also delete the spaces before and after the text. And the accents. * * @param string $string Text to clean * @param string $replacement (optional) Character to replace the special characters. Default: '-' * * @return string Cleaned text */ function wh_clean_string_from_special_chars($string,$replacement = '-') { // les accents $string = trim($string); //$string = strtr(utf8_decode($string),"ÀÃ�ÂÃÄÅàáâãäåÒÓÔÕÖØòóôõöøÈÉÊËèéêëÇçÌÃ�ÃŽÃ�ìíîïÙÚÛÜùúûüÿÑñ","aaaaaaaaaaaaooooooooooooeeeeeeeecciiiiiiiiuuuuuuuuynn"); $string = str_replace( array('à','á','â','ã','ä', 'ç', 'è','é','ê','ë', 'ì','í','î','ï', 'ñ', 'ò','ó','ô','õ','ö', 'ù','ú','û','ü', 'ý','ÿ', 'À','Ã�','Â','Ã','Ä', 'Ç', 'È','É','Ê','Ë', 'ÃŒ','Ã�','ÃŽ','Ã�', 'Ñ', 'Ã’','Ó','Ô','Õ','Ö', 'Ù','Ú','Û','Ü', 'Ã�'), array('a','a','a','a','a', 'c', 'e','e','e','e', 'i','i','i','i', 'n', 'o','o','o','o','o', 'u','u','u','u', 'y','y', 'A','A','A','A','A', 'C', 'E','E','E','E', 'I','I','I','I', 'N', 'O','O','O','O','O', 'U','U','U','U', 'Y'), $string ); // REPLACE ACCENTS MADE WITH TWO CHARACTERES (ACCENT + LETTER) $string = str_replace(array('aÌ€', 'aÌ�', 'aÌ‚', 'ã', 'ä', 'ç', 'eÌ€', 'eÌ�', 'eÌ‚', 'ë', 'iÌ€', 'iÌ�', 'iÌ‚', 'ï', 'ñ', 'oÌ€', 'oÌ�', 'oÌ‚', 'õ', 'ö', 'uÌ€', 'uÌ�', 'uÌ‚', 'ü', 'yÌ�', 'ÿ', 'AÌ€', 'AÌ�', 'AÌ‚', 'Ã', 'Ä', 'Ç', 'EÌ€', 'EÌ�', 'EÌ‚', 'Ë', 'IÌ€', 'IÌ�', 'IÌ‚', 'Ï', 'Ñ', 'OÌ€', 'OÌ�', 'OÌ‚', 'Õ', 'Ö', 'UÌ€', 'UÌ�', 'UÌ‚', 'Ü', 'YÌ�', '​'), array('à', 'á', 'â', 'ã', 'ä', 'ç', 'è', 'é', 'ê', 'ë', 'ì', 'í', 'î', 'ï', 'ñ', 'ò', 'ó', 'ô', 'õ', 'ö', 'ù', 'ú', 'û', 'ü', 'ý', 'ÿ', 'À', 'Ã�', 'Â', 'Ã', 'Ä', 'Ç', 'È', 'É', 'Ê', 'Ë', 'ÃŒ', 'Ã�', 'ÃŽ', 'Ã�', 'Ñ', 'Ã’', 'Ó', 'Ô', 'Õ', 'Ö', 'Ù', 'Ú', 'Û', 'Ü', 'Ã�', ''), $string); // les caracètres spéciaux (aures que lettres et chiffres en fait) $string = preg_replace('/([^.a-z0-9]+)/i', $replacement, $string); $string = strtolower($string); return $string; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 62
Branch analysis from position: 5
2 jumps found. (Code = 77) Position 1 = 11, Position 2 = 61
Branch analysis from position: 11
2 jumps found. (Code = 78) Position 1 = 12, Position 2 = 61
Branch analysis from position: 12
2 jumps found. (Code = 47) Position 1 = 25, Position 2 = 31
Branch analysis from position: 25
2 jumps found. (Code = 43) Position 1 = 32, Position 2 = 54
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 60
Branch analysis from position: 60
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
Branch analysis from position: 54
2 jumps found. (Code = 43) Position 1 = 57, Position 2 = 60
Branch analysis from position: 57
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
Branch analysis from position: 60
Branch analysis from position: 31
Branch analysis from position: 61
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 61
Branch analysis from position: 62
filename:       /in/0RnU7
function name:  (null)
number of ops:  72
compiled vars:  !0 = $args, !1 = $key, !2 = $value, !3 = $list, !4 = $multiselectValues, !5 = $multiselectValue, !6 = $valueKey, !7 = $multiselectKeyFromValue, !8 = $multiselectKey
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
    3     1        ASSIGN                                                   !1, 'subFunction'
    4     2        ASSIGN                                                   !2, 'Administratif%2CAsset+Management%2CCTO%2CAdministratif%2CAsset+Management%2CCTO%2CAdministratif%2CAsset+Management%2CCTO'
   17     3        ASSIGN                                                   !3, <array>
   64     4      > JMPZ                                                     !3, ->62
   65     5    >   INIT_FCALL                                               'explode'
          6        SEND_VAL                                                 '%2C'
          7        SEND_VAR                                                 !2
          8        DO_ICALL                                         $13     
          9        ASSIGN                                                   !4, $13
   69    10      > FE_RESET_R                                       $15     !4, ->61
         11    > > FE_FETCH_R                                       ~16     $15, !5, ->61
         12    >   ASSIGN                                                   !6, ~16
   70    13        INIT_FCALL_BY_NAME                                       'wh_clean_string_from_special_chars'
         14        SEND_VAR_EX                                              !5
         15        DO_FCALL                                      0  $18     
         16        ASSIGN                                                   !7, $18
   83    17        INIT_FCALL                                               'in_array'
         18        SEND_VAR                                                 !7
         19        INIT_FCALL                                               'array_keys'
         20        SEND_VAR                                                 !3
         21        DO_ICALL                                         $20     
         22        SEND_VAR                                                 $20
         23        DO_ICALL                                         $21     
         24      > JMPNZ_EX                                         ~22     $21, ->31
         25    >   INIT_FCALL                                               'array_search'
   84    26        SEND_VAR                                                 !5
   85    27        SEND_VAR                                                 !3
   83    28        DO_ICALL                                         $23     
         29        ASSIGN                                           ~24     !8, $23
         30        BOOL                                             ~22     ~24
         31    > > JMPZ                                                     ~22, ->54
   87    32    >   ECHO                                                     '%24multiselectKey+%3D%3E%3E'
   88    33        INIT_FCALL                                               'print_r'
         34        SEND_VAR                                                 !8
         35        DO_ICALL                                                 
   89    36        ECHO                                                     '%0A'
   90    37        COALESCE                                         ~27     !8
         38        QM_ASSIGN                                        ~27     !7
         39        ASSIGN_DIM                                               !4
         40        OP_DATA                                                  ~27
   91    41        ECHO                                                     '%24multiselectValues+add+%3D%3E%3E'
   92    42        INIT_FCALL                                               'print_r'
         43        SEND_VAR                                                 !4
         44        DO_ICALL                                                 
   93    45        ECHO                                                     '%0A'
   94    46        UNSET_DIM                                                !4, !6
   95    47        UNSET_CV                                                 !8
   96    48        ECHO                                                     '%24multiselectValues+unset+%3D%3E%3E'
   97    49        INIT_FCALL                                               'print_r'
         50        SEND_VAR                                                 !4
         51        DO_ICALL                                                 
   98    52        ECHO                                                     '%0A'
   83    53      > JMP                                                      ->60
  100    54    >   ARRAY_KEY_EXISTS                                 ~30     !5, !3
         55        BOOL_NOT                                         ~31     ~30
         56      > JMPZ                                                     ~31, ->60
  101    57    >   CONCAT                                           ~32     'multiselectValue+elseif+%3D%3E%3E', !5
         58        ECHO                                                     ~32
  102    59        ECHO                                                     '%0A'
   69    60    > > JMP                                                      ->11
         61    >   FE_FREE                                                  $15
  106    62    >   INIT_FCALL                                               'json_encode'
         63        SEND_VAR                                                 !4
         64        DO_ICALL                                         $34     
         65        ASSIGN_DIM                                               !0, !1
         66        OP_DATA                                                  $34
  107    67        INIT_FCALL                                               'print_r'
         68        SEND_VAR                                                 !0
         69        DO_ICALL                                                 
  108    70        ECHO                                                     '%0A'
  143    71      > RETURN                                                   1

Function wh_clean_string_from_special_chars:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0RnU7
function name:  wh_clean_string_from_special_chars
number of ops:  30
compiled vars:  !0 = $string, !1 = $replacement
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  123     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      '-'
  126     2        INIT_FCALL                                               'trim'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $2      
          5        ASSIGN                                                   !0, $2
  129     6        INIT_FCALL                                               'str_replace'
  130     7        SEND_VAL                                                 <array>
  131     8        SEND_VAL                                                 <array>
  132     9        SEND_VAR                                                 !0
  129    10        DO_ICALL                                         $4      
         11        ASSIGN                                                   !0, $4
  136    12        INIT_FCALL                                               'str_replace'
         13        SEND_VAL                                                 <array>
         14        SEND_VAL                                                 <array>
         15        SEND_VAR                                                 !0
         16        DO_ICALL                                         $6      
         17        ASSIGN                                                   !0, $6
  139    18        INIT_FCALL                                               'preg_replace'
         19        SEND_VAL                                                 '%2F%28%5B%5E.a-z0-9%5D%2B%29%2Fi'
         20        SEND_VAR                                                 !1
         21        SEND_VAR                                                 !0
         22        DO_ICALL                                         $8      
         23        ASSIGN                                                   !0, $8
  140    24        INIT_FCALL                                               'strtolower'
         25        SEND_VAR                                                 !0
         26        DO_ICALL                                         $10     
         27        ASSIGN                                                   !0, $10
  142    28      > RETURN                                                   !0
  143    29*     > RETURN                                                   null

End of function wh_clean_string_from_special_chars

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
159.65 ms | 1029 KiB | 23 Q