Hi; I'd like to ask you how to assign value by using loop instead of the following; $fruits = array("d" => "lemon", "a" => "orange", "b" => "banana", "c" => "apple");
Thanks
jatar_k
2:15 pm on Feb 1, 2008 (gmt 0)
where does the data come from?
coopster
5:42 pm on Feb 1, 2008 (gmt 0)
array_combine [php.net] may be an answer for you but it all depends on the current structure of your data, where it is located and/or where it comes from, as jatar_k has already mentioned.
xbl01234
10:38 pm on Feb 1, 2008 (gmt 0)
The datas from database.
i want select posttime and link from database, and reorder them by posttime desc.
PHP_Chimp
10:47 pm on Feb 1, 2008 (gmt 0)
//get info from database $array = array(); while ($row = mysql_fetch_array('...')) { $array[$row['posttime'] = $row['desc']; }
This code will only work assuming you only have a single desc for each posttime, as otherwise the later posttimes will over write the earlier ones. You will then have an array indexed by posttime, so you can sort the array into your order from there. Maybe ksort [uk3.php.net] would do what you want from there.
[edited by: PHP_Chimp at 10:48 pm (utc) on Feb. 1, 2008]