I have this little piece of text thatneeds to be altered. Calculations must be done on any number in the paragraph,except the numbers that we put into some custom 'holder'.
I'll illustrate:
If you buy 5 oranges, you will get them at a discount of 20%, so willonly pay 10e
this must be:
If you buy 5 oranges, you will get them at a discount of 20%, so willonly pay 8e
If we use this code:
$record = preg_replace('#(\d+)([.,](\d{1,2}))?#e', 'number_format("$1.$3" * 0.8,2, ",", ".")', $record);
This will give:
If you buy 4 oranges, you will get them at a discount of 16%, so willonly pay 8e
I figured i'd use this kind of code:
preg_match("/\[lit](.*)\[\/lit\]/",$str,$title);
Before the preg-replace function. By making the text look like this before the calculations take place:
If you buy [lit]5[/lit] oranges, you will get them at a discount of [lit]20%[/lit], so willonly pay 8e
something like this should make our import flawless. However i am not php-smart enough to comeup with the best code to use for this.
Could anybody here help me?
Cheers.