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; }

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
8.5.10.0130.00917.16
8.5.00.0100.01220.34
8.4.150.0020.00114.05
8.4.140.0100.01217.82
8.4.130.0110.00918.09
8.4.120.0050.00420.89
8.4.110.0140.00622.45
8.4.100.0100.00718.00
8.4.90.0080.00718.03
8.4.80.0080.00218.10
8.4.70.0140.00618.27
8.4.60.0120.00518.73
8.4.50.0060.00418.25
8.4.40.0090.00318.15
8.4.30.0060.01318.97
8.4.20.0110.01121.69
8.4.10.0060.00319.84
8.3.280.0020.00114.05
8.3.270.0120.00816.67
8.3.260.0120.00616.88
8.3.250.0050.00319.29
8.3.240.0120.00916.71
8.3.230.0120.00916.90
8.3.220.0030.00617.38
8.3.210.0070.00916.93
8.3.200.0060.00617.18
8.3.190.0070.01417.18
8.3.180.0090.01016.77
8.3.170.0000.01520.59
8.3.160.0090.00917.42
8.3.150.0080.01117.47
8.3.140.0050.00317.15
8.3.130.0060.00317.01
8.3.120.0040.00420.77
8.3.110.0130.01020.94
8.3.100.0050.00318.61
8.3.90.0070.00426.77
8.3.80.0060.00317.97
8.3.70.0110.01118.80
8.3.60.0450.00617.84
8.3.50.0090.01218.74
8.3.40.0380.01317.84
8.3.30.0340.00617.84
8.3.20.0330.00717.84
8.3.10.0260.01117.84
8.3.00.0300.00717.84
8.2.290.0130.00620.50
8.2.280.0060.00618.72
8.2.270.0170.00317.37
8.2.260.0090.00620.62
8.2.250.0040.00416.93
8.2.240.0100.00618.60
8.2.230.0090.00022.58
8.2.220.0030.00624.06
8.2.210.0060.01326.77
8.2.200.0000.01018.66
8.2.190.0110.01517.84
8.2.180.0250.00017.84
8.2.170.0150.01017.84
8.2.160.0190.00617.84
8.2.150.0170.01017.87
8.2.140.0240.00717.84
8.2.130.0160.01117.84
8.2.120.0210.00917.84
8.2.110.0200.01017.84
8.2.100.0190.00617.84
8.2.90.0160.00617.84
8.2.80.0140.00917.84
8.2.70.0230.00017.84
8.2.60.0110.01117.84
8.2.50.0160.00817.84
8.2.40.0120.01217.84
8.2.30.0160.00517.84
8.2.20.0230.00017.84
8.2.10.0170.00517.84
8.2.00.0170.00717.88
8.1.330.0030.00516.84
8.1.320.0120.00716.34
8.1.310.0110.00418.50
8.1.300.0030.00717.02
8.1.290.0060.00330.84
8.1.280.0190.00617.84
8.1.270.0160.01417.84
8.1.260.0280.00417.84
8.1.250.0340.00617.84
8.1.240.0180.01317.84
8.1.230.0250.00017.84
8.1.220.0150.00917.84
8.1.210.0200.00717.84
8.1.200.0240.00317.84
8.1.190.0330.00817.84
8.1.180.0330.01017.84
8.1.170.0210.00717.84
8.1.160.0210.00317.84
8.1.150.0200.00717.84
8.1.140.0230.00517.84
8.1.130.0190.00717.84
8.1.120.0190.00317.84
8.1.110.0130.00817.84
8.1.100.0190.00717.84
8.1.90.0150.00617.84
8.1.80.0210.00717.84
8.1.70.0340.00717.84
8.1.60.0290.01617.84
8.1.50.0300.00717.84
8.1.40.0280.00517.84
8.1.30.0270.00717.84
8.1.20.0300.00417.84
8.1.10.0350.00417.84
8.1.00.0300.00417.84

preferences:
35.86 ms | 403 KiB | 5 Q