PHP code example of php-kit / power-primitives

1. Go to this page and download the library: Download php-kit/power-primitives 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/ */

    

php-kit / power-primitives example snippets



use function PA;

$emails = PA($users)
    ->filter(fn ($user) => $user['isActive'])
    ->orderBy('lastLogin', SORT_DESC)
    ->map(fn ($user) => $user['email'])
    ->all();


use function PS;

echo PS('  Laravel ')
    ->trim()
    ->toUpperCase(); // outputs LARAVEL

$emails = [];
foreach ($users as $user) {
    if (!empty($user['active']) && isset($user['email'])) {
        $emails[] = strtolower($user['email']);
    }
}

$emails = PA($users)
    ->filter(fn ($user) => !empty($user['active']))
    ->getColumn('email')
    ->map('strtolower')
    ->all();
bash
composer 
bash
php tests/run.php