Page 1 of 1

str_replace problem

Posted: Fri Jun 27, 2008 12:26 am
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

Re: str_replace problem

Posted: Fri Jun 27, 2008 6:52 am
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().