For example there is a string :
$valeur = "a-b-c-b-d-e";
The letter “b” is present twice in this. I want to replace only the first “b”.
How to do that ? I used str_replace but it replaces all occurences.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You cab try preg_replace here.
Here 4th parameter is for limit and this is optional.
thanks