note 68429 deleted from ref.math by cmb

From: Date: Sun, 21 Jul 2019 08:57:16 +0000
Subject: note 68429 deleted from ref.math by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-211655@lists.php.net to get a copy of this message
Note Submitter: Evan Broder ---- A slightly more complex but much more accurate cardinal=>ordinal function (the one below doesn't account for 11th, 12th, and 13th, which don't follow the usual rules): <?php function ordinal($cardinal) { $cardinal = (int)$cardinal; $digit = substr($cardinal, -1, 1); $tens = substr($cardinal, -2, 1); if($tens == 1) { return $cardinal.'th'; } switch($digit) { case 1: return $cardinal.'st'; case 2: return $cardinal.'nd'; case 3: return $cardinal.'rd'; default: return $cardinal.'th'; } } ?>

« previous php.notes (#211655) next »