I have some strings like this: "The temperature is 18 Celsius today".
Some strings may have more than one value in them, like "The
temperature is 18 Celsius today. Yesterday is was 17 Celsius".
I want to display these, adding a tooltip when the mouse pointer is
over the "18C section, such that it shows the value in Fahrenheit
instead of Celsius. Something like this:
The temperature is <span class="temp" title="64 Fahrenheit">18
Celsius</span> today.
I need some way to do a string replace to add the <span>, but with a
calculation to work out the new value. Can preg_replace do something
like this?
Some strings may have more than one value in them, like "The
temperature is 18 Celsius today. Yesterday is was 17 Celsius".
I want to display these, adding a tooltip when the mouse pointer is
over the "18C section, such that it shows the value in Fahrenheit
instead of Celsius. Something like this:
The temperature is <span class="temp" title="64 Fahrenheit">18
Celsius</span> today.
I need some way to do a string replace to add the <span>, but with a
calculation to work out the new value. Can preg_replace do something
like this?
Comment