Sorting alphabetically backwards lists

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

    Sorting alphabetically backwards lists

    This code runs @ http://www.ckoogle.com but the trouble is once I get
    the list backwards, and in an array. I can't sort the new array into
    alphabetical order. Anyone know a way to do it?

    <?php

    echo '<form action="index.p hp" method="post">' ;
    echo '<textarea name="input" cols="12" rows="20">';
    echo '</textarea><br>';
    echo '<input type="submit" value="Submit"> ';
    echo '</form>';

    if( isset( $_POST["input"] )){
    $my_array = $_POST["input"];
    $my_array=strre v($my_array);
    $my_array=explo de("\n", $my_array);
    print_r($my_arr ay);
    sort($my_array) ;
    print_r($my_arr ay);
    for($cnt=0; $cnt < count($my_array ); $cnt++)
    {
    echo(strrev($my _array[$cnt]));
    echo('<br>');
    }
    }
    ?>

  • =?UTF-8?B?SXbDoW4gU8OhbmNoZXogT3J0ZWdh?=

    #2
    Re: Sorting alphabetically backwards lists

    CoreyWhite wrote:
    This code runs @ http://www.ckoogle.com but the trouble is once I get
    the list backwards, and in an array. I can't sort the new array into
    alphabetical order. Anyone know a way to do it?
    Sort the array, then transverse it using the foreach construct.

    --
    ----------------------------------
    Iván Sánchez Ortega -ivansanchez-algarroba-escomposlinux-punto-org-

    "Do, or do not. There is no 'try'."
    - Yoda ('The Empire Strikes Back')

    Comment

    • CoreyWhite

      #3
      Re: Sorting alphabetically backwards lists

      On Feb 17, 10:04 pm, Iván Sánchez Ortega <ivansanche...@ rroba--
      escomposlinux.p unto.netwrote:
      CoreyWhite wrote:
      This code runs @http://www.ckoogle.com but the trouble is once I get
      the list backwards, and in an array. I can't sort the new array into
      alphabetical order. Anyone know a way to do it?
      >
      Sort the array, then transverse it using the foreach construct.
      >
      --
      ----------------------------------
      Iván Sánchez Ortega -ivansanchez-algarroba-escomposlinux-punto-org-
      >
      "Do, or do not. There is no 'try'."
      - Yoda ('The Empire Strikes Back')

      Could you post the code changes I need please?

      Comment

      • Kimmo Laine

        #4
        Re: Sorting alphabetically backwards lists

        "CoreyWhite " <CoreyWhite@gma il.comwrote in message
        news:1171764363 .117909.311890@ v45g2000cwv.goo glegroups.com.. .
        This code runs @ http://www.ckoogle.com but the trouble is once I get
        the list backwards, and in an array. I can't sort the new array into
        alphabetical order. Anyone know a way to do it?
        Could you explain this with a bit more details. Now this sounds to me like
        you either shouldn't reverse it in the first place if you indeed want it
        sorted alphabetically or if you want it reversed, then I can't see the
        problem, it is in backwards alphabetical order. And furthermore, I don't see
        the "new" array anywhere, you opereate only one array, $my_array.
        <?php
        >
        echo '<form action="index.p hp" method="post">' ;
        echo '<textarea name="input" cols="12" rows="20">';
        echo '</textarea><br>';
        echo '<input type="submit" value="Submit"> ';
        echo '</form>';
        >
        if( isset( $_POST["input"] )){
        $my_array = $_POST["input"];
        $my_array=strre v($my_array);
        $my_array=explo de("\n", $my_array);
        print_r($my_arr ay);
        sort($my_array) ;
        print_r($my_arr ay);
        for($cnt=0; $cnt < count($my_array ); $cnt++)
        {
        echo(strrev($my _array[$cnt]));
        echo('<br>');
        }
        }
        ?>
        >

        Comment

        Working...