so i have an array of 20 numerical values (0-100) that i need to order from highest to lowest and then i need to retrieve the keys of the top ten values.
$array1 = array($a1,$a2,$a3,$a4,$a5,$a6,$a7,$a8,$a9,$a10,$a11,$a12,$a13,$a14,$a15,$a16,$a17,$a18,$a19,$a20);
arsort($array1);
<? print_r($array1);?>
which yields
Array ( [4] => 74 [12] => 70 [19] => 70 => 66 [3] => 66 [10] => 63 [2] => 62 [8] => 57 [11] => 57 [15] => 50 [14] => 50 [9] => 50 [1] => 50 [5] => 50 [17] => 30 [7] => 30 [18] => 30 [13] => 23 [16] => 23 [6] => 23 )
i figured how to return the key of the highest value
function max_extract($array1) {
return array_keys($array1, max($array1));
}
$max_key= max($array1);
but i can't figure out how to get the remainder of the top ten keys (i.e. 19,0,3,10,2,8,11,15,14).
any ideas?
Different actions for different parts of a string
<?phpfunction dosomething($string, $else = '') { if (empty($else)) $string = "<b>$string</b>"; else $string =
Retrieving Data from Two Different Databases
Hello All, Ran into another problem and would appreciate some help! I have two databases, publications_db (pub_id, title, author, yr, journal, num_pages) and
redirect standard error and assert (how to?)
How do you redirect standard error and assert?---(Why? I am creating an web app and assert does not show on the webpage. I do not think standard error does either. Not sure, but fairly certain.
Undefined variable: adHTML
Hello:While checking my site error logs, I've noticed one repetitive error that fills the log file. The error is "PHP Notice: Undefined variable: adHTML in /.../bot_jrheader.php on line
Reduce redundancies in switch functions?
Hello all! I somewhat new to PHP, and was wondering if anyone could give some suggestions on a switch function to reduce redundancies, and to efficaciously implement the script on to other
AJAX form submit
I recently built a form that submits data to my database with an ajax function that is called through onClick="function ..." on the submit button. That all works perfectly, however the
PHP Surveys
I really would like some advice.If you have a client come to you asking for a survey to be done with 117 questions each has 4 radio button check boxes, and a overall percentage needs to be tallyed up.
Help with search.php
Hello AllI need the search engine on a site I am building at the moment to display the search results inside the main section of the web page. At the moment I have got as far as connecting the search
Array help
Hello i got this code to fetch data from database but it is not working it displays7ArrayArrayArrayArrayArrayArrayCode: if (isset($_POST['showrecord'])){ $query='SELECT * FROM artus_test';
Need help PLEASE
ok i have this warning showing upWarning: in_array() [function.in-array]: Wrong datatype for second argument in /home/lalala/public_html/attack.php on line 72the code i use Code: [Select]//same ip