ecommit/scalar-values

测试标量值。

v1.1.0 2023-01-08 11:49 UTC

This package is auto-updated.

Last update: 2024-08-30 14:15:43 UTC


README

Tests

安装

要使用Composer安装scalar-values,只需运行

$ composer require ecommit/scalar-values

用法

测试数组是否只包含标量值

use Ecommit\ScalarValues\ScalarValues;

$array = ['str1', 2, 3];
if (ScalarValues::containsOnlyScalarValues($array)) { //True
    //...
} else {
    //...
}

$array = ['str1', ['tab'], 3];
if (ScalarValues::containsOnlyScalarValues($array)) { //False
    //...
} else {
    //...
}

返回删除所有非标量值后的输入数组(在根级别)

use Ecommit\ScalarValues\ScalarValues;

$array = ['str1', ['tab'], 3];
$newArray = ScalarValues::filterScalarValues($array); //[0 => 'str1', 2 => 3]

许可证

该库采用MIT许可证。请参阅LICENSE文件中的完整许可证。