> OK I am trying to take some content from another site (I have total
> consent)
> and convert all the prices on the site to 5% more. I can get all the
> content
> off the site and display it where I want. I can ereg_replace all the
money
> to one price such as ($23.50) but I can't change the price based on
what
> it
> was before
[snip]
> Select $20.25 from site a
> Convert it to $21.26
> So basically let P = current price on site A
> And P * .05 = price I want to display on my site.

How about this?

$adjusted_content = preg_replace('/\$([0-9]+\.[0-9]{2})/e',
'sprintf("$%01.2f",$1*0.05+$1)', $content);

It will take each occurrence of something like $23.22 and match the
23.22 part. It will then evaluate the code 

sprintf("$01.2f",$1*0.05+$1) 

where $1 is the 23.22 or whatever was matched. The sprintf will format
the output so that it's only two decimals. 

Hope that helps.

---John Holmes...



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to