User Name Password Register
DaniWeb IT Discussion Community
All
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
Reply
Join Date: Sep 2007
Posts: 13
Reputation: bhakti.thakkar is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
bhakti.thakkar bhakti.thakkar is offline Offline
Newbie Poster

help in merging of two array values

  #1  
Nov 13th, 2007
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...
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jun 2007
Location: Valley Center, Kansas
Posts: 636
Reputation: kkeith29 is on a distinguished road 
Rep Power: 3
Solved Threads: 71
kkeith29's Avatar
kkeith29 kkeith29 is online now Online
Practically a Master Poster

Re: help in merging of two array values

  #2  
Nov 13th, 2007
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'.
Last edited by kkeith29 : Nov 13th, 2007 at 5:58 pm.
Reply With Quote  
Join Date: Sep 2007
Posts: 13
Reputation: bhakti.thakkar is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
bhakti.thakkar bhakti.thakkar is offline Offline
Newbie Poster

Re: help in merging of two array values

  #3  
Nov 14th, 2007
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...


Originally Posted by kkeith29 View Post
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'.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb PHP Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 5:09 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC