any php studs arround

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Bird
    Confirmed User
    • Jan 2005
    • 4365

    #1

    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
    ICQ:268731675
  • Brujah
    Beer Money Baron
    • Jan 2001
    • 22157

    #2
    Not really sure what you're doing, but you want a loop?
    Code:
    foreach($c as $dt) {
        echo $dt;
    }

    Comment

    • Bird
      Confirmed User
      • Jan 2005
      • 4365

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


      Originally posted by Brujah
      Not really sure what you're doing, but you want a loop?
      Code:
      foreach($c as $dt) {
          echo $dt;
      }
      ICQ:268731675

      Comment

      • Fredde
        Confirmed User
        • Mar 2004
        • 501

        #4
        Do a for loop instead!
        for($i=0;$i<= $numrecords;$i++)
        {
        $string = $date[$i] . $time[$i];
        }
        -------------------------------------------
        Teen boobs | Elitecounter - Free counter service

        Comment

        • frank7799
          Confirmed User
          • Jul 2003
          • 1974

          #5
          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?

          Comment

          • Brujah
            Beer Money Baron
            • Jan 2001
            • 22157

            #6
            building $c array from $a and $b arrays? maybe:
            Code:
            $c = array();
            while( list($key,$value) = each($a) ) {
                $c[] = $a[$key].' '.$b[$key];
            }

            Comment

            • Bird
              Confirmed User
              • Jan 2005
              • 4365

              #7
              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;
              }



              Originally posted by Fredde
              Do a for loop instead!
              for($i=0;$i<= $numrecords;$i++)
              {
              $string = $date[$i] . $time[$i];
              }
              ICQ:268731675

              Comment

              • Fredde
                Confirmed User
                • Mar 2004
                • 501

                #8
                You're welcome!
                -------------------------------------------
                Teen boobs | Elitecounter - Free counter service

                Comment

                • Adultnet
                  Confirmed User
                  • Sep 2003
                  • 8713

                  #9
                  you are very much welcome


                  TrafficCashGold Paying Webmasters Since 1996!

                  Awesome Conversions! Fast Weekly Payments! Over 125 Tours!

                  Comment

                  Working...