PHP code example of kryshtalovich / algorithms

1. Go to this page and download the library: Download kryshtalovich/algorithms library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

kryshtalovich / algorithms example snippets


use Kryshtalovich\Algorithms\Sorts\Bubble;

//any numeric array
$array = [9, 7, 5, 6, 545, 66, 0, 4];


Bubble::Sort($array);

var_dump($array);

use Kryshtalovich\Algorithms\Search\Binary;

//any numeric array
$array = [7, 7.5, 8, 8.3, 9.4];

$elementKey = Binary::Search($array, 8.3);

var_dump($elementKey);

array(8) {
  [0]=>
  int(0)
  [1]=>
  int(4)
  [2]=>
  int(5)
  [3]=>
  int(6)
  [4]=>
  int(7)
  [5]=>
  int(9)
  [6]=>
  int(66)
  [7]=>
  int(545)
}