1. Go to this page and download the library: Download sven/heap 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/ */
sven / heap example snippets
# Push an item into the heap.
$heap->push('foo');
$heap->all(); // ['foo']
# Merge an existing array into the heap.
$heap->merge(['fizz', 'baz']);
$heap->all(); // ['foo', 'fizz', 'baz']
# Get the first or last item from the heap.
$heap->first(); // 'foo'
$heap->last(); // 'baz'
# Get the first or last `n` items from the heap.
$heap->first(2); // ['foo', 'fizz']
$heap->last(2); // ['fizz', 'baz']
# Pre- or append an item to the heap.
$heap->prepend('bar');
$heap->all(); // ['bar', 'foo', 'fizz', 'baz']
$heap->append('buzz');
$heap->all(); // ['bar', 'foo', 'fizz', 'baz', 'buzz']
$heap->random(); // 'baz' (retrieved randomly)
# Empty the entire array.
$heap->nuke();
$heap->all(); // []
php
# New up an instance of the class.
$heap = new Sven\Heap\Heap;
# You can also pass in an array to push to the heap.
$heap = new Sven\Heap\Heap(['foo', 'bar', 'baz']);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.