iPixel Posted December 10, 2009 Share Posted December 10, 2009 I need to write a script that will literally be ran just once, it's kidna like a fix i need to do in the database. I have a field called filenumber which contains a number such as 002707 and many more like it. all of them start off with zeros then the #'s. So employee # 1 would be 000001 and employee 1000 would be 001000. So you get get the idea. I need to remove those initial 0's to turn 002707 into 2707, and the 001000 into 1000's. here's how i invision this... Select data from table while results = fetch { take result[filenumber] use soem function to keep deleting zeros from left to right untill it hits a number other then 0. update the database row with the new filenumber. } So i guess what i really need is a function that will allow me to parse through the filenumber string, and remove those zeros, up to a # other then 0. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/184648-need-help-with-a-script/ Share on other sites More sharing options...
JonnoTheDev Posted December 10, 2009 Share Posted December 10, 2009 simple <?php $string = "00000123445"; $string = ereg_replace('^0{0,}', '', $string); print $string; ?> Quote Link to comment https://forums.phpfreaks.com/topic/184648-need-help-with-a-script/#findComment-974825 Share on other sites More sharing options...
iPixel Posted December 10, 2009 Author Share Posted December 10, 2009 Hah! Perfect! TYVM ! Quote Link to comment https://forums.phpfreaks.com/topic/184648-need-help-with-a-script/#findComment-974829 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.