Place £ symbol in front of first integer in variable


Is there an easy way to append a £ symbol in front of an integer.

So if the user types in:

Offers over 235,000

then my function will change this to
Offers over £235,000

Any ideas?

Many thanks


See money_format. :wink:


So instead of the £ symbol, it would just use GBP?

I think I may be a bit cheeky and just use 2 columns in the database to store ‘Offers over’ and ‘235,000’ :wink:

Thanks again Anthony

You could add more control by writing your own function, this is very messy but should get the point across.


 * @desc  Yeah, money-ize. I'm hip.
function moneyize($string, $prefix = '&pound;'){
  return preg_replace_callback(
        'return "%s" . number_format($num[0], 2);',

echo moneyize('Offers above 250000');
#Offers above &pound;250,000.00

echo moneyize('Offers above 250000', '$');
#Offers above $250,000.00


Thanks, Anthony!!! That looks pretty good. I’m hoping to play about with it shortly, see how I go.

Thanks again