str_replace problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
sanwar
Forum Newbie
Posts: 1
Joined: Fri Jun 27, 2008 12:16 am

str_replace problem

Post by sanwar »

I am having the following statements.

$formula=((( 5339) * ( 1 + Cess Duty + 0.14 * ( 1 + 0.02 + 0.01) + Packing & Forwarding) + Packing & Forwarding fixed));
$formula=str_replace($chk_row[tax_name],0,$formula);
Where $chk_row[tax_name] value is coming from database i.e. red marked value in above formula.
But in query "Packing & Forwarding" is coming before "Packing & Forwarding fixed". so in replace function both "Packing & Forwarding" gets replaced and only "0 fixed" remains in formula which results in error while evaluating formula.
Kindly suggest replace this value usnig regular expression.

Anybody can help me.....

Thanks in advance

Sandeep
User avatar
jayshields
DevNet Resident
Posts: 1912
Joined: Mon Aug 22, 2005 12:11 pm
Location: Leeds/Manchester, England

Re: str_replace problem

Post by jayshields »

What are you actually trying to do? Use [ php ] and [ /php ] tags to illustrate your script better. I doubt you're going to need str_replace().
Post Reply