note 79069 added to function.sort
| From: | atiqw at yahoo dot com | Date: | Fri, 09 Nov 2007 03:27:11 +0000 |
| Subject: | note 79069 added to function.sort | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-132138@lists.php.net to get a copy of this message | ||
I am having problem with sorting an array.
Here's my code and the output, help please. I tried sorting after saving into mysql, even mysql
didn't sort that array data properly, what's wrong? please help ...
-----
code
-----
<?php
$host="localhost";
$userName="root";
$pass="";
$list = array();
$j = 0;
$cn = mysql_connect($host, $userName, $pass);
mysql_select_db('test', $cn);
$sql = "select * from emp order by fname";
//pass to record set
$rs = mysql_query($sql, $cn);
while($row = mysql_fetch_array($rs))
{
print $row["keywords"]."<BR>\n";
$values = explode(",", $row["keywords"]);
for($i=0; $i<sizeof($values); $i++)
{
$list[$j++] = $values[$i];
}
}
print "<br><br>\n";
sort($list);
for($i=0; $i<sizeof($list); $i++){
echo $list[$i]."<br />\n";
$sql = "insert into keywords(keywords, display) values
('$list[$i]', '')";
//pass to record set
$rs = mysql_query($sql, $cn);
}
?>
-------
output
-------
AJax
c++
Cobol
development
jeaps
joseph
josh
kevin
orange
philip
programming
rob
shirt
suv
warraich
web
apple
atiq
Cars
computer
java
Pant
-----------------
Thanks in advance
Regards:
Atiq warraich
atiqw@yahoo.com
-----------------
----
Server IP: 208.69.120.35
Probable Submitter: 68.77.111.253
----
Manual Page -- http://www.php.net/manual/en/function.sort.php
Edit -- https://master.php.net/note/edit/79069
Del: integrated -- https://master.php.net/note/delete/79069/integrated
Del: useless -- https://master.php.net/note/delete/79069/useless
Del: bad code -- https://master.php.net/note/delete/79069/bad+code
Del: spam -- https://master.php.net/note/delete/79069/spam
Del: non-english -- https://master.php.net/note/delete/79069/non-english
Del: in docs -- https://master.php.net/note/delete/79069/in+docs
Del: other reasons-- https://master.php.net/note/delete/79069
Reject -- https://master.php.net/note/reject/79069
Search -- https://master.php.net/manage/user-notes.php