Nth Smallest Element

Find the nth smallest element in an array by sorting in ascending order.

Code

General
sort($arr);
return $arr[$n - 1];

Parameters

Array of numbers

Position (1-indexed)

Server

More PHP Snippets