diff --git a/Searching/Binary Search/PHP/BinarySearch.php b/Searching/Binary Search/PHP/BinarySearch.php new file mode 100644 index 00000000..35eb011e --- /dev/null +++ b/Searching/Binary Search/PHP/BinarySearch.php @@ -0,0 +1,26 @@ + $item){ + $rightIndex = $middleIndex - 1; + } + else{ + return $middleIndex; + } + } + return -1; + } + + // Simple demonstration of the function + $array = array(1, 2, 4, 5, 6, 8, 9, 10, 14); + echo binarySearch($array, 8); +?>