Solved

testing first character of a string

Posted on 2008-06-16
4
208 Views
Last Modified: 2012-05-05
Hi,
I have the first  part of a date which can be = "01"

How can i test for the "0" part of the string, and if its "0" then make the string = the the second number?

I.E. If $temp = "01" then $temp = "1"

0
Comment
Question by:markmchugh
  • 2
4 Comments
 
LVL 48

Accepted Solution

by:
hernst42 earned 500 total points
Comment Utility
if ($temp[0] == '0') $temp = $temp[1];
0
 
LVL 24

Expert Comment

by:glcummins
Comment Utility
if ('0' == substr($string, 0, 1))
{
   $string = substr($string, 1);
}
0
 
LVL 6

Expert Comment

by:psychic_zero
Comment Utility
Try this:
if substr($temp,0) == "0" 

{

   $temp = "1"; 

}

Open in new window

0
 
LVL 6

Expert Comment

by:psychic_zero
Comment Utility
Modified...
if substr($temp,0) == "0" 

{

   $temp = substr($temp,1); 

}

Open in new window

0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

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…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to dynamically set the form action using jQuery.

772 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

15 Experts available now in Live!

Get 1:1 Help Now