How to print alternate arraylist values from two arraylist?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Colin Rodrigues
    New Member
    • Dec 2010
    • 16

    #1

    How to print alternate arraylist values from two arraylist?

    I have 2 arraylist which have equal number of elements. I need to print these values alternatively in an html table..for eg:

    arraylist1 conatins: moviename1,movi ename2,movienam e3
    arraylist2 contains: 8.00pm, 9.00pm, 10pm

    Now, it has to be printed like this:

    =============== =============== ==============
    moviename1
    =============== =============== ==============
    8.00pm
    =============== =============== ==============
    moviename2
    =============== =============== ==============
    9.00pm
    =============== =============== ==============
    moviename3
    =============== =============== ==============
    10.00pm
    =============== =============== ==============

    I even have to add a <a> tag in the row which contains times. But first i have to print it alternatively.. any help would be appreciated.
  • code green
    Recognized Expert Top Contributor
    • Mar 2007
    • 1726

    #2
    I would use
    Code:
    $combarr = array_combine($arraylist1,$arraylist2)
    Then
    Code:
    foreach($combarr as $movie=>$time)
    echo $movie.'<br>===<br>'.$time

    Comment

    • Colin Rodrigues
      New Member
      • Dec 2010
      • 16

      #3
      thanx for your time and answer...howeve r i figured out a simple way to do it...it didnt strike me earlier...

      the code i wrote is:

      for (int i = 0; i < arraylist1.Coun t; i++ )
      {
      <tr>
      <td>
      Response.Write( arraylist1[i]);
      </td>
      </tr>

      <tr>
      <td>
      <a href="NextPage. aspx">
      Response.Write( arraylist2[i]);</a>
      </td>
      </tr>

      Comment

      • code green
        Recognized Expert Top Contributor
        • Mar 2007
        • 1726

        #4
        Huge apologies.
        I have submitted PHP code for a C# question.

        Comment

        • Colin Rodrigues
          New Member
          • Dec 2010
          • 16

          #5
          It's ok...thanks for ur time anyways..

          Comment

          Working...