GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   any php studs arround (https://gfy.com/showthread.php?t=885103)

Bird 02-01-2009 03:52 AM

any php studs arround
 
I have been spending houre on this and I can t come up with a solution. I have added a time and date form to one of my sites for an alert count down where the user sets up a countdown to an event. The form results are like this. I cant figure out the loop statement can someone help.
Code:

$a = array ( [0] => date1  ,[1] => date2  ,[2] => date3 )
$b  array ( [0] => time1  ,[1] => time2  ,[2] => time3 )

$c = array ( [0] =>date1 time1  ,[1] =>date2 time2  ,[2] =>date3 time3 ) //new combined array

looking for the output  like this 2009-05-15 23:59:59

date1 time1
date2 time2
date3 time3


Brujah 02-01-2009 04:22 AM

Not really sure what you're doing, but you want a loop?
Code:

foreach($c as $dt) {
    echo $dt;
}


Bird 02-01-2009 04:30 AM

I got the loop for $c but it's the loop through $a and $b i need to get the combined $c= date time


Quote:

Originally Posted by Brujah (Post 15418031)
Not really sure what you're doing, but you want a loop?
Code:

foreach($c as $dt) {
    echo $dt;
}



Fredde 02-01-2009 05:00 AM

Do a for loop instead!
for($i=0;$i<= $numrecords;$i++)
{
$string = $date[$i] . $time[$i];
}

frank7799 02-01-2009 05:04 AM

Try it with array_merge and a loop:

$array1 = array("color" => "red", 2, 4);
$array2 = array("a", "b", "color" => "green", "shape" => "trapezoid", 4);
$result = array_merge($array1, $array2);

Maybe thatīs what you are looking for?

Brujah 02-01-2009 05:18 AM

building $c array from $a and $b arrays? maybe:
Code:

$c = array();
while( list($key,$value) = each($a) ) {
    $c[] = $a[$key].' '.$b[$key];
}


Bird 02-01-2009 05:21 AM

:thumbsup:thumbsup:thumbsup many thanks, I can get what i need from here. It was the for $i count I was looking for ($date[$i] . $time[$i];) it seemed everything else was rewriting the array key.

$a = array (date1,date2,date3 ) ;
$b = array (time1,time2, time3 ) ;

for($i=0;$i<= count($a);$i++)
{
$string = $a[$i] ." ". $b[$i]."<br>";
echo $string;
}



Quote:

Originally Posted by Fredde (Post 15418096)
Do a for loop instead!
for($i=0;$i<= $numrecords;$i++)
{
$string = $date[$i] . $time[$i];
}


Fredde 02-01-2009 05:23 AM

You're welcome!

Adultnet 02-01-2009 07:51 AM

you are very much welcome :)


All times are GMT -7. The time now is 03:14 AM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123