- strpos: documentation ( source)
- strtolower: documentation ( source)
<?php
$matiere1 = 'Cotton 2';
$matiere2 = 'lol';
echo "Matiere1 : ".checkMatiere($matiere1)." - Matiere2 : ".checkMatiere($matiere2);
function checkMatiere($matiere){
$matiere = strtolower($matiere);
switch ($matiere) {
case (strpos($matiere, 'cotton') !== FALSE):
$matiere = 'coton';
break;
default:
$matiere = "KO";
break;
}
}