Jump to content

[SOLVED] Output numbers in images


cordoprod

Recommended Posts

$date = '19/07/2008';

$chars= str_split($date);

foreach($chars as $char)
{
    if(is_numeric($char)
        echo '<img src="' . $char . '.jpg" />';
    elseif($char == '/')
        echo '<img src="slash.jpg" />';
}

 

Thank you...

 

is_numeric.. if it is alphabetic letters which function should i use there then?

well you only specified with numbers. If it could be anything just move the condition for / up and remove the elseif:

 

$date = '19/07/2008';

$chars= str_split($date);

foreach ($chars as $char) {
    if($char == '/') {
        echo '<img src="slash.jpg" />';
    } else {
        echo '<img src="' . $char . '.jpg" />';
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.