PHP code example of blister / php-linkedlist
1. Go to this page and download the library: Download blister/php-linkedlist 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/ */
blister / php-linkedlist example snippets
$list = new Blister\LinkedList();
// Add to the end of the LinkedList
$list->push('Hello!');
$list->push('World!');
$list->push(array('key' => 'val'));
$list->push(true);
$list->push('Last!');
// Add to the front of the LinkedList
$list->unshift('New First!');
// Get the length of the LinkedList
$len = $list->length; // 6
// Searching inside the list
$found_index = $list->index('World!'); // 2
$found = $list->find('World'); // true
$found = $list->find('Missing'); // false
// removing elements
$last = $list->pop(); // 'Last!'
$first = $list->shift(); // 'First!'
$middle = $list->remove('World!'); // 'World!'
$third = $list->removeAt(1); // array('key' => 'val')