How to remove all leading zeroes in a string in PHP?

Posted by Prem Tiwari | Updated on

If you want to remove all leading zeroes in a string in PHP? Use $str = ltrim($str, '0');.

Example 1: remove all leading zeroes from string in PHP

Example 2: remove all leading zeroes from string in PHP using preg_replace() function


If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.

Related Questions & Answers