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.
Dans une phrase, je voudrai modifier tous les mots commençant par VT .
Ceci me remplace juste le mot complet "VT" comme tel c'est normal c'est ce que je lui demande me direz-vous :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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);
VTT STE MARIE ~VT VTC ARVTDER
Mais voulant avoir ça :
~VTT STE MARIE ~VT ~VTC ARVTDER je fais :
cela ne change rien malgré le i rajouté en fin de @\bVT\b@i
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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);
voyez-vous pourquoi cela ne marche pas, avez-vous une solution SVP .
Merci d'avance.
Partager