All Algorithms implemented in Php

Overview

The Algorithms - PHP

All algorithms implemented in Php (for education)

These implementations are for learning purposes. They may be less efficient than the implementations in the Php standard library.

Contribution Guidelines

Read our Contribution Guidelines before you contribute.

Community Channel

We're on Gitter! Please join us.

List of Algorithms

See our directory.

Comments
  • Add Mono-Alphabetic Cipher

    Add Mono-Alphabetic Cipher

    A mono-alphabetic cipher is a simple substitution cipher where each letter of the sentence is replaced with another letter of the alphabet. It uses a fixed key which consists of the 26 letters of a shuffled alphabet.

    opened by YvonneChong18 4
  • Do we allow for improvement PRs

    Do we allow for improvement PRs

    Hello @nikhilkala , can one make PRs to improve already existing solutions? An example is the factorial solution which will be faster for large numbers if a cache is implemented

    opened by prondubuisi 2
  • Add project euler p1 and p2

    Add project euler p1 and p2

    This PR add solution for project euler problem 1 and problem 2.


    Apart from this PR, i have questions and sugesstions for this repo:

    1. why not add psr-4 autoloading to composer.json file, something like:
    {
        "autoload": {
            "psr-4": {
                "TheAlgorithms\\PHP\\": "app/",
            }
        },
        "autoload-dev": {
            "psr-4": {
                "TheAlgorithms\\PHP\\Tests\\": "tests/"
            }
        },
    }
    

    imo, it would help manage namespaces and classes.

    current implementation: if i want to use factorial function from Maths\Factorial.php, i must require the file with:

    require_once 'path/to/Factorial.php';
    
    $x = factorial(100);
    

    but if we use namespace, we can do:

    // file: Math\Factorial.php
    namespace TheAlgorithms\PHP\Maths;
    
    function factorial($number) {
    //....
    }
    
    // file: Anywhere.php
    use function \TheAlgorithms\PHP\Maths\factorial;
    
    $x = factorial(100);
    

    or with classes and static function:

    // file: Math.php
    namespace TheAlgorithms\PHP;
    
    class Math {
        public static function factorial($number) {
        //....
        }
    }
    
    
    // file: Anywhere.php
    use \TheAlgorithms\PHP\Math;
    
    $x = Math::Factorial(100);
    
    1. i think it is better to use internal link in the DIRECTORY.md file instead of external link directly to github.
    // current
    ## Maths
      * [Absolutemax](https://github.com/TheAlgorithms/PHP/blob/master/Maths/AbsoluteMax.php)
    
    // propose:
    ## Maths
      * [Absolutemax](./Maths/AbsoluteMax.php)
    

    with that, we can browse the file locally from our clonned repo.

    1. what is the standard used here? i see the folder structure is kinda messy. there are lowercase folder, uppercase folder, camelcase fiename, etc. the tests folder is kinda messy too.

    2. is there limit on maximal run time per function on tests? i see the project euler problem 5 taking soo much time to complete the test. would it be nice to add some rule? or do the test in parallel? also, what if changing the test with https://pestphp.com? it has simple syntax and more great expectation api to simplify the tests.

    what do you think? i am happy to open a draft PR if any sugesstion is being considered.

    #cmiiw #cheers :beers:

    hacktoberfest-accepted 
    opened by lakuapik 2
  • Valid Quick Find implementation of the DisjointSet Graph data structure

    Valid Quick Find implementation of the DisjointSet Graph data structure

    I'll be adding many more. Adjacency matrix/list, BFS, DFS, Cycle Detection, spanning tree's, Shortest Path, etc all in PHP. This commit is just to get started 🙂

    opened by ideaguy3d 1
  • Add quickSort and update DIRECTORY.md

    Add quickSort and update DIRECTORY.md

    Quick sort is very fast! Uses array shift to create separate arrays (less than or greater than the current value) and merges them together when there are none left.

    opened by ghost 1
  • Update directory links

    Update directory links

    This PR updates directory link from external to internal. This will make sure the links still works for local repository.

    I also update the BASE_URL for the github action.

    hacktoberfest-accepted 
    opened by lakuapik 1
  • fix to bug in CheckPrime

    fix to bug in CheckPrime

    closes #38

    Bug

    isPrime() returns true to the square of a number, for example. isPrime(49) // return true instead of false

    fix

    -while ($i < sqrt($number)) {...}
    +while ($i <= sqrt($number)) {...}
    
    
    opened by emlycool 1
  • Added Lower and Upper Bound Functions

    Added Lower and Upper Bound Functions

    I have tried to adhere by Contributing Guidelines still if I missed something or made some error let me know and any further suggestions would be appreciated. Thanks.

    opened by Lakhan-Nad 1
  • PHP NLP Tools

    PHP NLP Tools

    I added few functions and a class to use NLP algorithms for string manipulation.

    Please review and let me know your ideas. Hope you will love my contribution and I will contribute more on using PHP NLP Tools.

    opened by asirihewage 1
  • Added geometry folder and square.php + geometryTest.php

    Added geometry folder and square.php + geometryTest.php

    Create a geometry folder. Add area + cirumference function for a square. A simple test for the both function with some test values in geometryTest.php

    opened by Kalinguar 1
  • Quicksort empty clause is not correct

    Quicksort empty clause is not correct

    Hi, the first clause of quickSort algorithm intended for checking empty inputs is using "isset" function which only checks for variable existence or null. So, if I call quickSort with an empty array ([ ]) this this clause will not work.

    Also, using isset inside this function has not sense because the $input parameter is always defined and it will be always an array (nulls are not allowed with this arguments definition), so it will always evaluate to true.

    I think it would be appropriate to use the "empty" function in this case instead.

    opened by lcavero 4
Owner
The Algorithms
Open Source resource for learning Data Structures & Algorithms and their implementation in any Programming Language
The Algorithms
A community driven collection of sorting algorithms in PHP

algorithms A community driven collection of sorting algorithms This repository includes a comma separated file that includes 10k numbers between 1 and

Andrew S Erwin 0 May 16, 2022
True asynchronous PHP I/O and HTTP without frameworks, extensions, or annoying code. Uses the accepted Fibers RFC to be implemented into PHP 8.1

PHP Fibers - Async Examples Without External Dependencies True asynchronous PHP I/O and HTTP without frameworks, extensions, or annoying code behemoth

Cole Green 121 Jan 6, 2023
:lipstick: Scalable and durable all-purpose data import library for publishing APIs and SDKs.

Porter Scalable and durable data imports for publishing and consuming APIs Porter is the all-purpose PHP data importer. She fetches data from anywhere

null 594 Jan 1, 2023
PHP Integrated Query, a real LINQ library for PHP

PHP Integrated Query - Official site What is PINQ? Based off the .NET's LINQ (Language integrated query), PINQ unifies querying across arrays/iterator

Elliot Levin 465 Dec 30, 2022
Map nested JSON structures onto PHP classes

JsonMapper - map nested JSON structures onto PHP classes Takes data retrieved from a JSON web service and converts them into nested object and arrays

Christian Weiske 1.4k Dec 30, 2022
A Collections library for PHP.

A Library of Collections for OO Programming While developing and helping others develop PHP applications I noticed the trend to use PHP's arrays in ne

Levi Morrison 629 Nov 20, 2022
Yet Another LINQ to Objects for PHP [Simplified BSD]

YaLinqo: Yet Another LINQ to Objects for PHP Online documentation GitHub repository Features The most complete port of .NET LINQ to PHP, with many add

Alexander Prokhorov 436 Jan 3, 2023
🗃 Array manipulation library for PHP, called Arrayy!

?? Arrayy A PHP array manipulation library. Compatible with PHP 7+ & PHP 8+ \Arrayy\Type\StringCollection::create(['Array', 'Array'])->unique()->appen

Lars Moelleken 430 Jan 5, 2023
`LINQ to Object` inspired DSL for PHP

Ginq Array handling in PHP? Be happy with Ginq! Ginq is a DSL that can handle arrays and iterators of PHP unified. Ginq is inspired by Linq to Object,

Atsushi Kanehara 191 Dec 19, 2022
Collections Abstraction library for PHP

Collections Collections Abstraction library for PHP The Collection library is one of the most useful things that many modern languages has, but for so

Ítalo Vietro 62 Dec 27, 2021
Leetcode for PHP, five questions a week and weekends are updated irregularly

✏️ Leetcode for PHP why do you have to sleep for a long time ,and naturally sleep after death 联系 说明 由于目前工作主要是 golang,我又新起了一个LeetCode-Go-Week项目,- Leetc

吴亲库里 370 Dec 29, 2022
Missing data types for PHP. Highly extendable.

Neverending data validation can be exhausting. Either you have to validate your data over and over again in every function you use it, or you have to rely it has already been validated somewhere else and risk potential problems.

SmartEmailing 82 Nov 11, 2022
JsonMapper - map nested JSON structures onto PHP classes

Takes data retrieved from a JSON web service and converts them into nested object and arrays - using your own model classes.

Netresearch 9 Aug 21, 2022
Iterators - The missing PHP iterators.

PHP Iterators Description The missing PHP iterators. Features CachingIteratorAggregate ClosureIterator: ClosureIterator(callable $callable, array $arg

(infinite) loophp 24 Dec 21, 2022
A collection of common algorithms implemented in PHP. The collection is based on "Cracking the Coding Interview" by Gayle Laakmann McDowell

PHPAlgorithms A collection of common algorithms implemented in PHP. The collection is based on "Cracking the Coding Interview" by Gayle Laakmann McDow

Doğan Can Uçar 921 Dec 18, 2022
YCOM Impersonate. Login as selected YCOM user 🧙‍♂️in frontend.

YCOM Impersonate Login as selected YCOM user in frontend. Features: Backend users with admin rights or YCOM[] rights, can be automatically logged in v

Friends Of REDAXO 17 Sep 12, 2022
REST APIs using Slim framework. Implemented all CRUD operations on the MySql database

PHP REST API using slim framework and CRUD operations ?? Hi there, this is a simple REST API built using the Slim framework. And this is for the folks

Hanoak 2 Jun 1, 2022
A repository with implementations of different data structures and algorithms using PHP

PHP Data Structures and Algorithms Data structure and Algorithm is always important for any programming language. PHP, being one of the most popular l

Mizanur Rahman 610 Jan 2, 2023
A community driven collection of sorting algorithms in PHP

algorithms A community driven collection of sorting algorithms This repository includes a comma separated file that includes 10k numbers between 1 and

Andrew S Erwin 0 May 16, 2022
Goldbach Algorithms Mask is a PHP library developed for Symfony for apply a mask to strings.

Goldbach Algorithms Mask (fondly nicknamed GoldMask) is a PHP library developed for Symfony for apply a mask to strings.

Goldbach Algorithms 1 Oct 30, 2021