WordPress strip leading zero from post title

0

In working with a client recently I had the special case instance where the client had named the post titles based on a set numeric naming convention as they were using their wordpress instance as more of a CMS to serve special data.  The titles were being pulled dynamically from MySQL and had a leading zero due to the data type of the table.  The client wanted the leading zero stripped from the title of each post.

To accomplish this, we setup a post template in which we used the ltrim function in php to trim the leading zero as follows:

<?php

$title = get_the_title();
$title_edit = ltrim($title, '0');

echo "<h3><strong><center><span style=color:#ff0000;>$title_edit</span></strong></center></h3>";

?>

As can be seen, the code, gets the post title, passes that to the $title variable and then the $title_edit variable gets its value by trimming the ‘0’ from the front of the $title variable.  Then the $title_edit variable is echoed in the post template.  There are probably other fancy ways of doing this same trick, however, for our purposes the ltrim function worked well in the post template to get rid of the leading ‘0’ in this special case instance.