preg_replace début de caractères
Bonjour à tous,
Un petit problème de preg_replace que me pourrit la journée depuis ce matin, voila je voudrai solliciter votre lumière pour m'éclairer :ccool: .
Dans une phrase, je voudrai modifier tous les mots commençant par VT .
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
$phrase = "VTT STE MARIE VT VTC ARVTDER";
$findconfli = array(
'@\bVT\b@'
);
$remplaceconfli = array(
'~VT'
);
$phrase=preg_replace($findconfli,$remplaceconfli,$phrase); |
Ceci me remplace juste le mot complet "VT" comme tel c'est normal c'est ce que je lui demande me direz-vous :
VTT STE MARIE ~VT VTC ARVTDER
Mais voulant avoir ça :
~VTT STE MARIE ~VT ~VTC ARVTDER je fais :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
$phrase = "VTT STE MARIE VT VTC ARVTDER";
$findconfli = array(
'@\bVT\b@i'
);
$remplaceconfli = array(
'~VT'
);
$phrase=preg_replace($findconfli,$remplaceconfli,$phrase); |
cela ne change rien malgré le i rajouté en fin de @\bVT\b@i
voyez-vous pourquoi cela ne marche pas, avez-vous une solution SVP .
Merci d'avance.