PHP Classes

PHP Array Sort and Search Algorithms: Search and sort arrays using common algorithms

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStarStar 66%Total: 315 All time: 7,262 This week: 206Up
Version License PHP version Categories
array-algorithms 1.1MIT/X Consortium ...5.0Algorithms, PHP 5, Searching, Data types
Description 

Author

This package search and sort arrays using common algorithms.

There is one class that can sort arrays using the algorithms bubble sort, comb sort, selection sort, heap sort and insertion sort.

Another class can implement array search algorithms like binary search, kmp search (Knuth-Morris-Pratt), and jump search.

Picture of Yousaf Syed
  Performance   Level  
Name: Yousaf Syed <contact>
Classes: 6 packages by
Country: Pakistan Pakistan
Age: 33
All time rank: 232430 in Pakistan Pakistan
Week rank: 48 Up2 in Pakistan Pakistan Up
Innovation award
Innovation award
Nominee: 4x

Winner: 1x

Example

<?php
include ('autoload.php');

$x = 4;
$list = array(5,2,3,4,1);


//Sort Algorithms examples
// $list = Algorithms\Sort::insertion_sort($list);
// $list = Algorithms\Sort::comb_sort($list);
// $list = Algorithms\Sort::selection_sort($list);
// $list = Algorithms\Sort::heap_sort($list);
// $list = Algorithms\Sort::bubble_sort($list);


// // Search Algorithms examples

// echo Algorithms\Search::binary_search($list, $x);
// echo Algorithms\Search::jump_search($x, $list);
// echo Algorithms\Search::kmp_search("ABC ABCDAB ABCDABCDABDE", "ABCDABD"); // 15


// Stack Example
// $stack = new Containers\Stack();
// $stack->push("hellow");
// $stack->push(2);
// $stack->push(3);
// $stack->push(4);
// $stack->push(5);
// echo $stack->top();




  Files folder image Files (8)  
File Role Description
Files folder imagesrc (2 directories)
Accessible without login Plain text file .travis.yml Data Auxiliary data
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file examples.php Example Example script
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file readme.md Lic. Auxiliary data

  Files folder image Files (8)  /  src  
File Role Description
Files folder imagealgorithms (2 files)
Files folder imagecontainers (1 file)

  Files folder image Files (8)  /  src  /  algorithms  
File Role Description
  Plain text file Search.php Class Class source
  Plain text file Sort.php Class Class source

  Files folder image Files (8)  /  src  /  containers  
File Role Description
  Plain text file Stack.php Class Class source

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:315
This week:0
All time:7,262
This week:206Up
User Ratings User Comments (1)
 All time
Utility:93%StarStarStarStarStar
Consistency:100%StarStarStarStarStarStar
Documentation:-
Examples:93%StarStarStarStarStar
Tests:-
Videos:-
Overall:66%StarStarStarStar
Rank:549
 
Great library
9 years ago (Mubasher Ahmad)
70%StarStarStarStar