iceman023 Posted April 21, 2009 Share Posted April 21, 2009 I have created a successfull php couter but i was wondering if i can make my own numbers to be displayed, so that it look alot better then just, "1234" Thanks Quote Link to comment https://forums.phpfreaks.com/topic/155101-php-counter-custom-numbers/ Share on other sites More sharing options...
AdRock Posted April 21, 2009 Share Posted April 21, 2009 css? Quote Link to comment https://forums.phpfreaks.com/topic/155101-php-counter-custom-numbers/#findComment-815870 Share on other sites More sharing options...
laffin Posted April 21, 2009 Share Posted April 21, 2009 u mean images or custom fonts? if u use images, u will be using gd2 library to create a canvass and than piece together the individual numbers Quote Link to comment https://forums.phpfreaks.com/topic/155101-php-counter-custom-numbers/#findComment-815871 Share on other sites More sharing options...
iceman023 Posted May 1, 2009 Author Share Posted May 1, 2009 Yes thats exactly what i want. Ill create images of the numbers 0-9 thats no prob but how do i get them to show up? Quote Link to comment https://forums.phpfreaks.com/topic/155101-php-counter-custom-numbers/#findComment-823270 Share on other sites More sharing options...
laffin Posted May 1, 2009 Share Posted May 1, 2009 Well u need the images of the numbers I came up with this code <?php // Get and update our counter $counter=(file_exists('counter.txt') && (($counter=file_get_contents('counter.txt'))>0))?$counter+1:1; file_put_contents('counter.txt',$counter); // Max Numbers to appear on counter define('MAX_NUMBERS',3); // Pad Counter with 0's $counter=substr(str_repeat('0',MAX_NUMBERS).$counter,-MAX_NUMBERS); // Get Number Images Attributes (Width & Height) $iinfo=getimagesize('pics/0.gif'); $cw=$iinfo[0]; $ch=$iinfo[1]; // Calculate Max Width $iw=$cw*MAX_NUMBERS; // Create image canvas for counter $ci=imagecreate($iw,$ch); // Loop to get image of each digit for($i=0;$i<MAX_NUMBERS;$i++) { // Grab Next Number in $counter $num=substr($counter,$i,1); // If Number use number image otherwise blank $num=ctype_digit($num)?$num:'blank'; // Do We have the image already? if(!isset($images[$num])) // No, Load the image $images[$num] = imagecreatefromgif("pics/{$num}.gif"); // Place image in correct place on new counter image imagecopy($ci,$images[$num],$i*$cw,0,0,0,$cw,$ch); } // tell browser we displaying a gif header('Content-type: image/gif'); // Show our image imagegif($ci); ?> See nothing to it, just make shure gd2 extension is loaded. Well up to u to take this and make it better Quote Link to comment https://forums.phpfreaks.com/topic/155101-php-counter-custom-numbers/#findComment-823429 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.