Jump to content

code explanation


jimfog

Recommended Posts

The code that follows outputs the date as css class in a td element:

id=dateid_'.$year.str_pad(date('m', $month),2,'0', STR_PAD_LEFT).str_pad($datecount, 2, '0', STR_PAD_LEFT).

This a segment, enough though to draw a conclusion-I believe, hopefully. And here is what is output in the browser:

<td class="weekdaysid=dateid_20120601">1</td>

The PHP code above outputs the ...id=dateid_20120601 and it is here that my q comes and is related with the str_pad function According to the PHP manual if the pad length is equal to the input string then no padding takes place.So, in the code we have a pad length of 2 and the input string is always 2 characters since date('m') outputs the month as 2 digits. So is there a reason for having a pad length of 2 here?

Link to comment
Share on other sites

I think it was dsonesuk sometime ago(I am almost sure he was him).

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...