/php-binary-search

This Composer package focused on efficient binary searching in PHP. Ideal for quickly locating elements in large sorted arrays.

Primary LanguagePHPMIT LicenseMIT

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.