Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Aug 2002
    Location
    Oregon, United States of America
    Posts
    882
    Thanks
    1
    Thanked 9 Times in 9 Posts

    array_multisort only works once.

    PHP Code:
    array_multisort($fillSORT_ASCSORT_NUMERIC);
    $x=0;
    while(
    $x count($fill)){
    print
    ", $fill[$x]";
    $x++;

    The first time i do this, $fill is rearranged perfectly.
    The second time i do this, it won'y rearrange.

    Any ideas?
    (BTW: THanks for everyones help. I've had lots of questions latly)
    Last edited by Ultragames; 10-17-2004 at 02:52 AM.
    If I'm postin here, I NEED YOUR HELP!!

  • #2
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    i don't understand the question or code.

    The sort is only called once (since it's outside the while-loop) so what do you mean by
    The second time i do this, it won'y rearrange.
    and you are using a while loop with an incrementing variable (it's kinda the convention to use $i for an incrementing variable) where you better use a for-loop. Like
    PHP Code:
    for ($i=0$i count($fill); print', ' $fill[$i], $i++); 
    or the better readable
    PHP Code:
    for ($i=0$i count($fill); $i++){
        print 
    ', ' $fill[$i]; 

    Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html

  • #3
    Senior Coder
    Join Date
    Aug 2003
    Location
    One step ahead of you.
    Posts
    2,815
    Thanks
    0
    Thanked 3 Times in 3 Posts
    I advise to do all for loops with count() (or any other function) to be written like this:
    PHP Code:
    <?
    for ($i=0$n count($fill); $i $n$i++)

       print 
    ', ' $fill[$i];  
    }
    ?>
    The expresion in the second agument of the for loop is checked every time the loop goes thru the code so It will count fill as many times as the code is looped.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •