codwelt/helpersman

为php, laravel及更多世界提供的辅助函数

v2.8.0 2024-07-16 21:55 UTC

This package is auto-updated.

Last update: 2024-09-16 22:19:13 UTC


README

为php程序员提供的脚本、方法和辅助对象。

特点

Helpersman 方法

  • random_string($length, $keyspace)

    生成一个指定长度的随机字符串,由 keyspaces 中的字符组成

    • $length : 要生成的字符串大小
    • $keyspace : 用于生成字符串的字符集,默认为 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ,如未指定
  • purificate_string($string, $remplaceTo, $regex)

    删除特殊字符、换行符以及非字母或数字的所有内容

    • $string : 在其中搜索和替换字符的字符串
    • $remplaceTo : 替换字符的内容,默认为空,如未指定
    • $regex : 用于替换字符的搜索模式。默认为 /[^A-Za-z0-9]/,如未指定。
  • count_words_repeated($text, $deleteAcent, $distinction_lowercase, $words_excluyed) 对文本中的所有重复和重复的单词进行计数

    • $text: 要计数的文本
    • $deleteAcent: 默认为 true,是一个标志,表示是否删除单词中的重音符号
    • $distinction_lowercase: 默认为 false,是一个标志,表示是否在计数单词时考虑大小写区别
    • $words_excluyed: 默认为一个空数组。是一个数组,包含不希望计数的单词列表
  • delete_acents($string)

    负责删除输入字符串中的重音符号

        <?php
        use Codwelt\HelpersMan\HelpersMan;
        
        $text = "este es un un texto de prueba";
        $countWords = HelpersMan::count_words_repeated($text);
        var_dump($countWords);

    结果将类似于这样

    array(6) {
      ["un"]=>
      int(2)
      ["este"]=>
      int(1)
      ["es"]=>
      int(1)
      ["texto"]=>
      int(1)
      ["de"]=>
      int(1)
      ["prueba"]=>
      int(1)
    }

时间方法

是用于处理时间的方法

安装

PHP

在纯PHP环境中安装,需要在设备上安装 composer

在项目中使用控制台

composer require codwelt/helpersman

有了这些,就可以使用该包了

<?php
use Codwelt\HelpersMan\HelpersMan;

$ramdom = HelpersMan::random_string(10);