How to leave the first 4 characters of a string smaller than the others

0

I did a search and did not find a code to leave only the first 4 characters of a string with a smaller size.

I tried this code:

$str = "Códigos"; 
$str = strtolower($str);

Only I need to leave are the first 4 numbers smaller than the others. What I always find are related to strings .

    
asked by anonymous 08.01.2016 / 19:02

2 answers

5

I think it might solve like this:

$numero = '1234567890';
echo '<small>'.substr($numero, 0, 4).'</small>'.substr($numero, 5);

Using substr I separated the string into 2 parts, one with the first 4% numbers .substr(0, 4) and another with the remaining .substr(5) and added the <small> tag to show in a smaller font.

The result will look like this in the browser:

<small>1234</small>567890
    
08.01.2016 / 19:05
2

In php you can make a substr() to get the first 4 positions and then use the <font> to place it lower.

Example:

$str = "Gabriel Rodrigues";

function examplo($str) {
   return "<font size='1'>" . substr($str, 0, 4) . "</font>" . substr($str, 5);
}

echo examplo($str);
    
08.01.2016 / 19:20