PHP code example of vk-php-utils / ds

1. Go to this page and download the library: Download vk-php-utils/ds 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/ */

    

vk-php-utils / ds example snippets


use VKPHPUtils\DS\ArrayList;

$list = new ArrayList(1, 2, 3);
$list->add(4);
$list->remove(2);

foreach ($list as $element) {
    echo $element . PHP_EOL;
}

use VKPHPUtils\DS\Set;

$set = new Set(1, 2, 3, 3, 4);
$set->add(5);
$set->remove(2);

foreach ($set as $element) {
    echo $element . PHP_EOL;
}


use VKPHPUtils\DS\Map;

/** @var User $user1 **/
$user1 = ...;
/** @var User $user2 **/
$user2 = ...;

/** @var Map<User, Address> $addressMap **/
$addressMap = new Map();
$addressMap->put($user1, new Address('Apple str 18'));
$addressMap[$user2] = new Address('Banana str 19'); // php way

echo $map->get($user1)->street; // Output: Apple str 18

// php way
echo $map[$user1]->street; // Output: Apple str 18