•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 456,234 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,745 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 1050 | Replies: 2
![]() |
•
•
Join Date: Sep 2007
Posts: 13
Reputation:
Rep Power: 2
Solved Threads: 0
i have an array of hours[] and minutes[].
hours Array:
Array ( [0] => 11 [1] => 12 [2] => 13 [3] => 14 )
minutes[] Array:
Array ( [0] => 30 [1] => 30 [2] => 30 [3] => 30 )
now i want an array which will merge hours[] and time[] and give me an time[] array someting like below:
time Array:
Array ( [0] => 11:30 [1] => 12:30 [2] => 13:30 [3] => 14:30 )
how can i do it...
hours Array:
Array ( [0] => 11 [1] => 12 [2] => 13 [3] => 14 )
minutes[] Array:
Array ( [0] => 30 [1] => 30 [2] => 30 [3] => 30 )
now i want an array which will merge hours[] and time[] and give me an time[] array someting like below:
time Array:
Array ( [0] => 11:30 [1] => 12:30 [2] => 13:30 [3] => 14:30 )
how can i do it...
•
•
Join Date: Jun 2007
Location: Valley Center, Kansas
Posts: 636
Reputation:
Rep Power: 3
Solved Threads: 71
there probably is a simpler way but i made this i about 3 mins.
all of the times are now stored in an array in the variable '$time'.
<?php
$hours = array(11,12,13,14);
$mins = array(30,30,30,30);
$count = count($hours);
$i = 0;
while ($i < $count) {
$time[] = $hours[$i] . ":" . $mins[$i];
$i++;
}
?>all of the times are now stored in an array in the variable '$time'.
Last edited by kkeith29 : Nov 13th, 2007 at 5:58 pm.
•
•
Join Date: Sep 2007
Posts: 13
Reputation:
Rep Power: 2
Solved Threads: 0
Hi,
Thanks 4 ur reply
. i did it as below:
for($i = 0; $i < count($hours); $i++)
$time[$i] = $hours[$i] . ':' . $minutes[$i];
same way but with a for loop...
Thanks 4 ur reply
. i did it as below:for($i = 0; $i < count($hours); $i++)
$time[$i] = $hours[$i] . ':' . $minutes[$i];
same way but with a for loop...
•
•
•
•
there probably is a simpler way but i made this i about 3 mins.
<?php $hours = array(11,12,13,14); $mins = array(30,30,30,30); $count = count($hours); $i = 0; while ($i < $count) { $time[] = $hours[$i] . ":" . $mins[$i]; $i++; } ?>
all of the times are now stored in an array in the variable '$time'.
![]() |
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- Processing array values (PHP)
- Assigning Array Values En Masse (Java)
- 2d array (C)
- Is there a way to tokenize an array of strings (C++)
- Functions and Array help (C++)
- Help with copying an array into a struct (C)
- Array Values not found in Methods (Java)
- help with polymorphism and inheritance...getting null values (Java)
Other Threads in the PHP Forum


Linear Mode