I have a text like this
$text="The tower is 94.5m high,
the view is up to 100km.
The entrance is 8€";
Now I want to provide the tooltip for each metrics or currencies to get the result like this:
$text="The tower is <abbr title="310ft">94.5m</a> high,
the view is up to <abbr title="62mi">100km</abbr>.
The entrance is <abbr title="10USD">8€</abbr>
Some nice PHP function to convert these numbers automatically within the text? Thanks.
edit
To make this example simple, let’s suppose we have fix rates everywhere. The question is, what kind of preg_replace or whatever to use… I used only something like this
preg_replace("/(.*)€/", $1*1.2, $text)
that is just an example how I was expecting to make it work, but of course it is not. 🙂
Something like the following:
You’ll need to adjust the regexp and write additional cases for any other UOM conversion units you’re likely to need, and use the correct figures in the actual conversions (I just used quick and dirty values), and any formatting of the numbers too… but it should give you the basis.