Convert Database/Variable Name to Human Title


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <?
  2. class inflector extends inflector_Core {
  3. public static function titlize($rawTitle) {
  4. if(strlen($rawTitle) < 3) {
  5. return strtoupper($rawTitle);
  6. } else {
  7. return ucwords(self::humanize($rawTitle));
  8. }
  9. }
  10. }
  11.  
  12. echo inflector::titlize("news_items"); // News Items
  13. echo inflector::titlize("id"); // ID
  14. ?>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.