View Single Post
  #4 (permalink)  
Old Sep 3rd, 2007, 05:25
begeiste begeiste is offline
Junior Member
Join Date: Nov 2006
Location: us
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Re: multisort problem

Quote:
Originally Posted by c010depunkk View Post
I think your problem is where the red is, not the array_multisort function...
Code: Select all
 <?php
    $class=array("score" =>array(123,345,23,66,7,821,10,33,90,100), "name" =>array("Alice","Peter","Elvin","Sindy","Simon","Bob","Hank","Charlie","Caroline","Linda"));
    `
        
    array_multisort($class["score"],SORT_NUMERIC, SORT_DESC, $class["name"], SORT_STRING, SORT_ASC);
    
    
    echo "<table bgcolor='#ffff99' border='2' width='80%'>";
    echo "<tr><th>Score</th>";
    for($a=0; $a<10; $a++){
        echo "<td>".$class["score"][$a]."</td>";
    }
    echo "</tr><tr><th>Name</th>";
    for($a=0; $a<10; $a++){
        echo "<td>".$class["name"][$a]."</td>";    
    }
?>
I think you'd be better off using single quotes:
PHP: Select all

<?php
    $class
=array("score" =>array(123,345,23,66,7,821,10,33,90,100), "name" =>array("Alice","Peter","Elvin","Sindy","Simon","Bob","Hank","Charlie","Caroline","Linda"));

    
array_multisort($class["score"],SORT_NUMERICSORT_DESC$class["name"], SORT_STRINGSORT_ASC);
    
    
    echo 
"<table bgcolor='#ffff99' border='2' width='80%'>";
    echo 
"<tr><th>Score</th>";
    for(
$a=0$a<10$a++){
        echo 
"<td>".$class['score'][$a]."</td>";
    }
    echo 
"</tr><tr><th>Name</th>";
    for(
$a=0$a<10$a++){
        echo 
"<td>".$class['name'][$a]."</td>";    
    }
?>
I got it. It works fine. Thanks a lot.
Reply With Quote