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 5 of 5
  1. #1
    Regular Coder
    Join Date
    Jan 2007
    Posts
    154
    Thanks
    52
    Thanked 0 Times in 0 Posts

    Change Font Size

    Hi guys. If I echo a string. I.e

    PHP Code:
     <small><i>complete by <?PHP echo $deadline;  ?></i></small>
    Is there a way I can take $deadline and make the last 2 characters increase in font size?

  • #2
    New Coder
    Join Date
    Aug 2011
    Posts
    46
    Thanks
    9
    Thanked 2 Times in 2 Posts
    Get the string length and then echo each character individually..
    PHP Code:
    <?php
    $length 
    strlen($deadline);
    $last $deadline[$length-2];
    $slast $deadline[$length-1];
    $length -= 2;
    for (
    $i 1$i <= $length$i++) {
        if(
    $limiter <= $length) {
        echo 
    $deadline[$limiter];
        
    $limiter += 1;
        }    
    }
    echo 
    '<small style="size: 2px">' $last $slast '</small>';
    ?>
    That should fetch the length of $deadline and then echo each character individually and set the last 2 to a smaller size, change the "size: yypx" to whatever you want..

    Hope that helps

    - Matthew
    Last edited by GreenFanta; 08-22-2011 at 11:29 AM.

  • Users who have thanked GreenFanta for this post:

    thoford75 (08-22-2011)

  • #3
    Regular Coder
    Join Date
    Jan 2007
    Posts
    154
    Thanks
    52
    Thanked 0 Times in 0 Posts
    Genius! Thanks

  • #4
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    That's a waste. Use a substr to pull off what you need:
    PHP Code:
    $sText 'this is text';
    $sMostText substr($sText0, -2);
    $sLastTwo substr($sText, -2); 
    Format $sMostText and $sLastTwo as you see fit and concat.

  • Users who have thanked Fou-Lu for this post:

    thoford75 (08-22-2011)

  • #5
    Regular Coder
    Join Date
    Jan 2007
    Posts
    154
    Thanks
    52
    Thanked 0 Times in 0 Posts
    Even better Thanks both!


  •  

    Posting Permissions

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