Voting

: three plus zero?
(Example: nine)

The Note You're Voting On

shadikka at gmail dot com
20 years ago
My version of the centered string, it decreases the font number (since I've noticed smaller numbers are smaller fonts) until 1 if the string won't fit. Then it will give up.

<?php
function imagestringcentered ($img,$font,$cy,$text,$color) {
while (
strlen($text) * imagefontwidth($font) > imagesx($img)) {
if (
$font > 1) { $font--; }
else { break; }
}
imagestring($img,$font,imagesx($img) / 2 - strlen($text) * imagefontwidth($font) / 2,$cy,$text,$color);
}
?>

<< Back to user notes page

To Top