Minute 5 to 05?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
kahwooi
Forum Commoner
Posts: 25
Joined: Fri Dec 10, 2004 12:28 am

Minute 5 to 05?

Post by kahwooi »

How to do that? cast it to string, but how to do it?

$time_minute_list_value = array();
for ($m = 0 ; $m <= 55 ; $m += 5) {
array_push($time_minute_list_value, $m);
}

I get this ( [0] => 0 [1] => 5 [2] => 10 [3] => 15 [4] => 20 [5] => 25 [6] => 30 [7] => 35 [8] => 40 [9] => 45 [10] => 50 [11] => 55 ), but how can I change the value for 0 and 5 to 00 and 05?

Thank you.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

User avatar
aerodromoi
Forum Contributor
Posts: 230
Joined: Sun May 07, 2006 5:21 am

Post by aerodromoi »

Or by checking whether $num < 10:

Code: Select all

($num < 10) ? $out_str = "0".strval($num) : $out_str = strval($num);
Post Reply