Code example: echo ltrim(“005″,”0″);
Returned value: 5
3 thoughts on “How To – Remove Leading Zeros”
And, just because it’s tagged PHP/MySQL…
mysql> SELECT TRIM( LEADING 0 FROM 00124000 );
+———————————+
| TRIM( LEADING 0 FROM 00124000 ) |
+———————————+
| 124000 |
+———————————+
1 row in set (0.00 sec)
And, just because it’s tagged PHP/MySQL…
mysql> SELECT TRIM( LEADING 0 FROM 00124000 );
+———————————+
| TRIM( LEADING 0 FROM 00124000 ) |
+———————————+
| 124000 |
+———————————+
1 row in set (0.00 sec)
You could also use a cast: (int)$str
Good points to make Joe and Toby, thanks.