Solved

trim leading zero

Posted on 2006-10-24
2
785 Views
Last Modified: 2013-12-12
I have 04 written in a database. i am need to echo the variable but trim the leading zero.  Is there a php function to do this?
0
Comment
Question by:lvollmer
  • 2
2 Comments
 
LVL 29

Expert Comment

by:TeRReF
ID: 17798254
The fastest way to do this:

$var = '04';
print((int)$var);
0
 
LVL 29

Accepted Solution

by:
TeRReF earned 500 total points
ID: 17798298
If you want a function, use this:

<?php
$var = '04';
print(intval($var));
?>
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Consider the following scenario: You are working on a website and make something great - something that lets the server work with information submitted by your users. This could be anything, from a simple guestbook to a e-Money solution. But what…
Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now