sorting two arrays

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Terry Richards

    sorting two arrays

    this is prolly too simple but i got a brain block

    i have two arrays, one is days[1-7] and the other is
    timeofday[a-l],<each letter represents a time on the hour>
    how do is sort by days and put each day's list in order of time?
    so that i get a list in order of days and each day is in order of
    time...i can put in order by day or time but they always end up with
    whatever is the other order wrong.

    if ( isset($_GET['sort']) && $_GET['sort']=='call_days' ) {
    $_SESSION['sort'] = 'call_days'; }

    if ( isset($_GET['sort']) && $_GET['sort']=='call_time' ) {
    $_SESSION['sort'] = 'call_time'; }

    and:

    <?php if ($_SESSION['sort']!='call_time') { echo '<a
    href="',$_SERVE R['PHP_SELF'],'?sort=call_ti me">Call Time</a>'; } else {
    echo 'Call Time &darr;'; } ?>

    <?php if ($_SESSION['sort']!='call_days') { echo '<a
    href="',$_SERVE R['PHP_SELF'],'?sort=call_da ys">Call Days</a>'; } else {
    echo 'Call Days &darr;'; } ?>

    :-)^2
  • Geoff Berrow

    #2
    Re: sorting two arrays

    I noticed that Message-ID:
    <mBmGd.13722$BP 1.12819@bignews 4.bellsouth.net > from Terry Richards
    contained the following:
    [color=blue]
    >i have two arrays, one is days[1-7] and the other is
    >timeofday[a-l],<each letter represents a time on the hour>
    >how do is sort by days and put each day's list in order of time?
    >so that i get a list in order of days and each day is in order of
    >time...i can put in order by day or time but they always end up with
    >whatever is the other order wrong.
    >
    > if ( isset($_GET['sort']) && $_GET['sort']=='call_days' ) {
    >$_SESSION['sort'] = 'call_days'; }
    >
    > if ( isset($_GET['sort']) && $_GET['sort']=='call_time' ) {
    >$_SESSION['sort'] = 'call_time'; }
    >
    >and:
    >
    ><?php if ($_SESSION['sort']!='call_time') { echo '<a
    >href="',$_SERV ER['PHP_SELF'],'?sort=call_ti me">Call Time</a>'; } else {
    >echo 'Call Time &darr;'; } ?>
    >
    ><?php if ($_SESSION['sort']!='call_days') { echo '<a
    >href="',$_SERV ER['PHP_SELF'],'?sort=call_da ys">Call Days</a>'; } else {
    >echo 'Call Days &darr;'; } ?>[/color]

    Maybe I have brain block too but that code seems to have nothing to do
    with the question.
    --
    Geoff Berrow (put thecat out to email)
    It's only Usenet, no one dies.
    My opinions, not the committee's, mine.
    Simple RFDs http://www.ckdog.co.uk/rfdmaker/

    Comment

    • Terry Richards

      #3
      Re: sorting two arrays

      Geoff Berrow wrote:[color=blue]
      > I noticed that Message-ID:
      > <mBmGd.13722$BP 1.12819@bignews 4.bellsouth.net > from Terry Richards
      > contained the following:
      >
      >[color=green]
      >>i have two arrays, one is days[1-7] and the other is
      >>timeofday[a-l],<each letter represents a time on the hour>
      >>how do is sort by days and put each day's list in order of time?
      >>so that i get a list in order of days and each day is in order of
      >>time...i can put in order by day or time but they always end up with
      >>whatever is the other order wrong.
      >>
      >> if ( isset($_GET['sort']) && $_GET['sort']=='call_days' ) {
      >>$_SESSION['sort'] = 'call_days'; }
      >>
      >> if ( isset($_GET['sort']) && $_GET['sort']=='call_time' ) {
      >>$_SESSION['sort'] = 'call_time'; }
      >>
      >>and:
      >>
      >><?php if ($_SESSION['sort']!='call_time') { echo '<a
      >>href="',$_SER VER['PHP_SELF'],'?sort=call_ti me">Call Time</a>'; } else {
      >>echo 'Call Time &darr;'; } ?>
      >>
      >><?php if ($_SESSION['sort']!='call_days') { echo '<a
      >>href="',$_SER VER['PHP_SELF'],'?sort=call_da ys">Call Days</a>'; } else {
      >>echo 'Call Days &darr;'; } ?>[/color]
      >
      >
      > Maybe I have brain block too but that code seems to have nothing to do
      > with the question.[/color]

      well now, what i am looking to do is explained as best as i can. what
      does this code do? i am thinking i need to do for each day:
      (day[1-7])(time[a-l])starting with day1-a getting a total of 72
      interations ending with (day7-l)

      :-)^2

      Comment

      • News Me

        #4
        Re: sorting two arrays

        Terry Richards wrote:[color=blue]
        > Geoff Berrow wrote:
        >[color=green]
        >> I noticed that Message-ID:
        >> <mBmGd.13722$BP 1.12819@bignews 4.bellsouth.net > from Terry Richards
        >> contained the following:
        >>
        >>[color=darkred]
        >>> i have two arrays, one is days[1-7] and the other is
        >>> timeofday[a-l],<each letter represents a time on the hour>
        >>> how do is sort by days and put each day's list in order of time?
        >>> so that i get a list in order of days and each day is in order of
        >>> time...i can put in order by day or time but they always end up with
        >>> whatever is the other order wrong.
        >>>
        >>> if ( isset($_GET['sort']) && $_GET['sort']=='call_days' ) {
        >>> $_SESSION['sort'] = 'call_days'; }
        >>>
        >>> if ( isset($_GET['sort']) && $_GET['sort']=='call_time' ) {
        >>> $_SESSION['sort'] = 'call_time'; }
        >>>
        >>> and:
        >>>
        >>> <?php if ($_SESSION['sort']!='call_time') { echo '<a
        >>> href="',$_SERVE R['PHP_SELF'],'?sort=call_ti me">Call Time</a>'; } else
        >>> { echo 'Call Time &darr;'; } ?>
        >>>
        >>> <?php if ($_SESSION['sort']!='call_days') { echo '<a
        >>> href="',$_SERVE R['PHP_SELF'],'?sort=call_da ys">Call Days</a>'; } else
        >>> { echo 'Call Days &darr;'; } ?>[/color]
        >>
        >>
        >>
        >> Maybe I have brain block too but that code seems to have nothing to do
        >> with the question.[/color]
        >
        >
        > well now, what i am looking to do is explained as best as i can. what
        > does this code do? i am thinking i need to do for each day:
        > (day[1-7])(time[a-l])starting with day1-a getting a total of 72
        > interations ending with (day7-l)[/color]

        That makes it clear as a pint of Guiness... Show us the code that (1)
        loads the arrays and (2) sorts them.

        NM

        --
        convert uppercase WORDS to single keystrokes to reply

        Comment

        Working...