Skip to content

Latest commit

 

History

History
15 lines (8 loc) · 397 Bytes

README.md

File metadata and controls

15 lines (8 loc) · 397 Bytes

PHP BINARY SEARCH

Installation

To install the PHP Binary Search package, simply use Composer:

composer require alanx15a2/php-binary-search

Useage example

Important Note: Binary search can only be performed on a SORTED ARRAY!

array_search_binary($array, $target);

If the target element is found, the function will return the key of the element. Otherwise, it will return -1.