Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Senior Coder jcdevelopment's Avatar
    Join Date
    Oct 2007
    Location
    Cowboy Nation
    Posts
    2,182
    Thanks
    174
    Thanked 257 Times in 257 Posts

    Finding the last 2 characters of a string and adding a different font size

    I have a menu where the dollar amounts are larger than the cent amounts, in font sizes. ex: 7.99. Below i am trying to find this and replace with the new font size. However this does not seem to work.

    Does anyone have a suggestion or perhaps another way to approach this issue? Thanks.

    PHP Code:
    $small "<fontsize=4>";
    $price "799";
    $string preg_replace("/([0-9]{1,4})\.([0-9]{2})/","\$1.".".$small.\$2",$price);
    $price $string;
    $helper->addTextBlock('menu'$price); 

  • #2
    Regular Coder
    Join Date
    May 2011
    Posts
    240
    Thanks
    1
    Thanked 56 Times in 55 Posts
    Use the following code and style the amounts with css.
    PHP Code:
    $price preg_replace('#\b(\d{1,4})\.(\d{2})\b#''<span class="dollars-amount">\1</span><span class="cents-amount">.\2</span>'$price); 


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •