• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 220
  • 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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

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