help with arrays
Posted: Tue Mar 11, 2008 5:00 pm
~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:
Posting Code in the Forums to learn how to do it too.
Can I do the following, which finds the nth largest value from an array, using a 2d array, that finds the nth largest from each.
Here is my code using the 1d array, please modify for the 2d array. Any help is appriciated.
~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:
Posting Code in the Forums to learn how to do it too.
Can I do the following, which finds the nth largest value from an array, using a 2d array, that finds the nth largest from each.
Here is my code using the 1d array, please modify for the 2d array. Any help is appriciated.
Code: Select all
<?php
function nthlargest($array,$n)
{
rsort($array);
return $array[$n-1];
}
$my_array=array(1,2,3,4,5);
$x=3;
$value=size($my_array,$x);
echo "$value";
?>
~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: