RE: [PHP] Phasing HTML

2002-11-18 Thread John W. Holmes
> 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




[PHP] Phasing HTML

2002-11-18 Thread Brian Lee
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

I am using the following ereg_replace statements to change all the prices, I 
have tried several different ideas on how to change them bases on what they 
were before but have yet to succeed.

$code = ereg_replace('[^[:space:]][0-9][0-9][0-9][0-9][^0-9][0-9][0-9]', 
(string) $stupid, $code);
$code = ereg_replace('[^[:space:]][0-9][0-9][0-9][^0-9][0-9][0-9]', (string) 
$stupid, $code);
$code = ereg_replace('[^[:space:]][0-9][0-9][^0-9][0-9][0-9]', (string) 
$stupid, $code);
$code = ereg_replace('[^[:space:]][0-9][^0-9][0-9][0-9]',  (string) $stupid, 
$code);

I know that the ereg_replace statements aren’t right for what I want to do 
but I need to make them to figure out what regular expressions to use.

Here is what I am trying to make happen:

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.



Thanks for any help

-Brian






_
Protect your PC - get McAfee.com VirusScan Online 
http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963


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