PHP code example of kyledong / php-tools

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

    

kyledong / php-tools example snippets




ledong\PhpTools\Str;

// 字符串长度
return Str::len('hello');

// 截取字符串
return Str::substr('hello',1,4);

// 字符串是否包含子串
if (Str::contain('hello','h')) {
    return true;
} else {
    return false;
}

// 字符串是否以子串开头
if (Str::first('hello','h')) {
    return true;
} else {
    return false;
}

// 字符串是否以子串结尾
if (Str::end('hello','h')) {
    return true;
} else {
    return false;
}

// 字符串是否包含中文
if (Str::checkChr('hello')) {
    return true;
} else {
    return false;
}

// 生成指定长度的随机数
return Str::random(6);

// 字符串转小写
return Str::lower('hello');

// 字符串转大写
return Str::upper('hello');

// 生成UUID
return Str::uuid();




ledong\PhpTools\Arr;

// 二维数组排序
return Arr::multiSort([['id' => 1,'id' => 2]],'id','desc');

// 截取数组
return Arr::slice([['id' => 1,'id' => 2]],0,1);




ledong\PhpTools\Time;

// 获取当前毫秒
return Time::getCurrentMilis();

// 当前时间
return Time::getTime();

// 昨天
return Time::previous(1);

// 明天
return Time::future(1);

// 时间戳转化为时间
return Time::convertTimestampToTime('1678631379');




ledong\PhpTools\Security;

// 加密
return Security::encryptOpenssl('hello','qufclqupfdjvls24jfkjsl')

// 解密
return Security::decryptOpenssl('tLF9lTPugc6xYkofIVk2CQ==','qufclqupfdjvls24jfkjsl');

shell
composer