PHP code example of hexastudio / array_disk

1. Go to this page and download the library: Download hexastudio/array_disk 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/ */

    

hexastudio / array_disk example snippets




// Create new array disk object
$ard = new Array_Disk();

$data = array( 'Value 0', 'Value 1', 'Value 2' );

$ard->store($data); // Store a whole array in array disk object

$ard->length(); // Get current array length (return 3)

$ard->append('Value 3'); // Append value to array disk object

$ard->push('Value 4'); // Alias of append

$ard->length(); // return 5

$ard->pop(); // Remove last element from array disk object and return the last element (return 'Value 4')

$ard->get(1); // Get array value in key 1 (return 'Value 1')

$ard->merge(array('Value 5', 'Value 6')); // Merge array disk object with another array

$ard->length(); // return 6

$ard->slice(2, 3); // return array('Value 2', 'Value 3', 'Value 4')

$filename = $ard->get_filename(); // Get filename of array disk object storage

$ard->read(); // Read array value from the first line (return 'Value 0')
$ard->read(); // return 'Value 1'
$ard->read(); // return 'Value 2'
$ard->read(); // return 'Value 3'
$ard->read(); // return 'Value 5'
$ard->read(); // return 'Value 6'

$ard->rewind(); // Reset cursor back to the first line

$ard->sort(); // Sort data