• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 216
  • Last Modified:

testing first character of a string

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
markmchugh
Asked:
markmchugh
  • 2
1 Solution
 
hernst42Commented:
if ($temp[0] == '0') $temp = $temp[1];
0
 
glcumminsCommented:
if ('0' == substr($string, 0, 1))
{
   $string = substr($string, 1);
}
0
 
psychic_zeroCommented:
Try this:
if substr($temp,0) == "0" 
{
   $temp = "1"; 
}

Open in new window

0
 
psychic_zeroCommented:
Modified...
if substr($temp,0) == "0" 
{
   $temp = substr($temp,1); 
}

Open in new window

0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now