PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
~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.
~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.
<?php
$mine=array(array(1,2,3,4,5),
array(6,7,8,9,10));
$x=5;
$answer=nthlargest($mine,$x);
echo "$answer";
function nthlargest($array,$n)
{
foreach($array as $itm =>$indv)
{
rsort($indv);
foreach($indv as $sum)
{
return $sum[$n-1];
}
}
}
~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.