Skip to content

Instantly share code, notes, and snippets.

@Solution
Created October 22, 2011 22:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Solution/1306541 to your computer and use it in GitHub Desktop.
Save Solution/1306541 to your computer and use it in GitHub Desktop.
Price
<?php
function cutPrice($price, $delimiter = 3)
{
$pieces = array_reverse(str_split(strrev($price), $delimiter));
(string)$fprice = null;
(int)$i = 0;
foreach($pieces as $piece)
{
if($i == 0)
{
$fprice .= strrev($piece);
}else{
$fprice .= '&nbsp;' . strrev($piece);
}
++$i;
}
return $fprice;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment