It works fine for me. All I can say is that I’m not sure why you’re using strval as I can only assume you have names in the database and not php variables and secondly I removed a line with $old2 and $new2 which had not been assigned in the code you just provided.
Thanks for your reply,
actually, it works like that but if you get the $res_array[‘field’] from DB. just try to put a test data in fields/table and grab it via query and then preform this function … you will get my problem
Then thats suggesting a potential problem with your database. You have just said yourself that my example works so clearly str_replace is not at fault. Something is wrong with the result coming from the database. You need to do a var_dump and post that here before we can help any further
Var_dump the rows one by one and post them here - maybe we can spot something.
OMG? - IS there really any need to be sarcastic? - If you’re going to be like that then I won’t help any further.
You came here and posted a SAMPLE of how you were using str_replace which was not even your real code. You then posted your real code which I’ve tested and found to work. I’ve then asked you to use var_dump on each row from the database and post them here. You’re now OMG’ing me and attempting to make me look stupid when you from the very start have been misleading about your problem.
Either post the var_dumps or don’t ask for help on irrelevant source code which isn’t your actual code. All I am asking you for is debug output. There is absolutely no need to OMG me and try to make me look stupid. I am at least trying to help you and last time I checked I was the only one.
I have proven that str_replace is working and you agreed. If the data you are supplying to it is not being replaced then there is a fault with it. I would also suggest you right click and look at the source of the dumps in case there are any symbols there that the browser isn’t displaying to you.
Sound to me like a problem with character sets. If the database is stored in UTF8 and the PHP file in ISO-8859-1 for example than the characters are different, even though the look the same.
Make sure you have the same charset everywhere and try it then.