...

View Full Version : Change Font Size



thoford75
08-22-2011, 09:23 AM
Hi guys. If I echo a string. I.e



<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?

GreenFanta
08-22-2011, 10:25 AM
Get the string length and then echo each character individually..


<?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

thoford75
08-22-2011, 11:03 AM
Genius! Thanks

Fou-Lu
08-22-2011, 02:49 PM
That's a waste. Use a substr to pull off what you need:


$sText = 'this is text';
$sMostText = substr($sText, 0, -2);
$sLastTwo = substr($sText, -2);

Format $sMostText and $sLastTwo as you see fit and concat.

thoford75
08-22-2011, 03:03 PM
Even better :) Thanks both!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum