Web Analytics Made Easy -
StatCounter Change Font Size - CodingForum

Announcement

Collapse
No announcement yet.

Change Font Size

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new 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
    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; Aug 22, 2011, 05:29 AM.

    Comment


    • #3
      Genius! Thanks

      Comment


      • #4
        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.
        PHP Code:
        header('HTTP/1.1 420 Enhance Your Calm'); 
        Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

        Comment


        • #5
          Even better Thanks both!

          Comment

          Working...
          X
          😀
          🥰
          🤢
          😎
          😡
          👍
          👎