bruno_boccara
asked on
STR_REPLACE TROUBLE
Hello, I have a problem using str_replace and I'm wandering if it's not a bug of PHP.
I'm using PHP 5.3.5 compiled with MSVC6 (Visual C++ 6.0) , running with Apache 2.2.17 and windows 2008 server
I want to replace only the first occurence of a string:
$num_of_replace = 1;
str_replace("REF_PRODUIT", " COUNT(*) ","SELECT REF_PRODUIT FROM PRODUITS WHERE REF_PRODUIT = 'BIN24101' ",$num_of_replace)
the expected result is
SELECT COUNT(*) FROM PRODUITS WHERE REF_PRODUIT = 'BIN24101' // GOOD
but it seem to not use the parameter $num_of_replace and it replace ALL occurences:
SELECT COUNT(*) FROM PRODUITS WHERE COUNT(*) = 'BIN24101' // NOT GOOD
is there anything wrong in my code ??
Thanks for yur help !
I'm using PHP 5.3.5 compiled with MSVC6 (Visual C++ 6.0) , running with Apache 2.2.17 and windows 2008 server
I want to replace only the first occurence of a string:
$num_of_replace = 1;
str_replace("REF_PRODUIT",
the expected result is
SELECT COUNT(*) FROM PRODUITS WHERE REF_PRODUIT = 'BIN24101' // GOOD
but it seem to not use the parameter $num_of_replace and it replace ALL occurences:
SELECT COUNT(*) FROM PRODUITS WHERE COUNT(*) = 'BIN24101' // NOT GOOD
is there anything wrong in my code ??
Thanks for yur help !
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
YOU'r right
I just see this right now...
I should use preg_replace instead.....
I just see this right now...
I should use preg_replace instead.....
ASKER
SORRY SORRY
I DIDN'T SEE R-Byter ANSWER !!!
How can I fix my mistake ???
I DIDN'T SEE R-Byter ANSWER !!!
How can I fix my mistake ???
You can report it to mods.
But its not so important. Im glad that you have working solution. Those are my points.
Regards
But its not so important. Im glad that you have working solution. Those are my points.
Regards
I've no objection if you want to re-open the question and assign the points differently. I'm not exactly short of points.......
ASKER
at least I will give 250 points to each of you for your help !
I ask for the moderator ....
I ask for the moderator ....
@bportlock:
Just to be clear that I wasn't complaining. :)
Just to be clear that I wasn't complaining. :)
@R-Byter - It's OK. This is the correct thing to do. I was surprised to have my contribution accepted, I expected perhaps an assist, no more.
ASKER
Thanks to R-Byter and to bportlock for your help !!!
You're welcome.
ASKER
http://bugs.php.net/bug.php?id=11457