assist with SORT array

From: Date: Mon, 09 Sep 2002 20:27:57 +0000
Subject: assist with SORT array
Groups: php.db 
Request: Send a blank email to php-db+get-21647@lists.php.net to get a copy of this message
I have a head scratcher.. prob just a glitch on my side, but somehow I am confused with the results. I have a php script pulling from a mysql database for id/names which is getting choices through a check box form. All of that works just fine, but I wanted to display the results sorted by title. My snippet of code is: // $restaurants = array() of ids back from form
        for($i=0;$i<sizeof($restaurants);$i++) {
            $rest_id = $restaurants[$i];
            $sql="select name from restaurants where id=$rest_id";
            $result=mysql_query($sql) or die($sql . mysql_error());
            while($row=mysql_fetch_object($result)) {
                $rest_name .= ucwords(stripslashes($row->name)) . ";";
            }
        }
        $rest_array=explode(";",$rest_name);
        $rest_sort=sort($rest_array);		// <-- the problem line
        die("checking: $rest_name<br><br> size = ".sizeof($rest_array) . " sorted: " . sizeof($rest_sort));
the results come back with 6 in the $rest_array but only 1 in the $rest_sort array! How is that?? checking: Hi-Ho Tavern;Village Inn;Speak Easy;Duane's House Of Pizza;Atomic Coffee; size = 6 sorted: 1 What I am trying to accomplish is an array('Atomic Coffee', 'Duane's House Of Pizza','Hi-Ho Tavern','Speak Easy','Village Inn') Help?? Terry Romine Web Developer JumpInteractive.com

« previous php.db (#21647) next »