PHPize Online / SQLize Online

Articles    Popular

How to find the closest number in an array?

Tags: PHP 5.x PHP 7.x PHP 8.x

Question: Given a number. What way to find the number closest to given in unsorted array?

Unsorted numbers array: [5, 56, 23, 1, 89, 3]
Number: 90


  Use this link for 
    run and share PHP code

If you find an error on this page, please contact us via feedback form