https://github.com/e-commit/scalar-values
Test scalar values
https://github.com/e-commit/scalar-values
php scalar-values
Last synced: about 1 month ago
JSON representation
Test scalar values
- Host: GitHub
- URL: https://github.com/e-commit/scalar-values
- Owner: e-commit
- License: mit
- Created: 2020-02-08T15:56:56.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2025-03-15T13:17:47.000Z (2 months ago)
- Last Synced: 2025-04-14T04:14:50.080Z (about 1 month ago)
- Topics: php, scalar-values
- Language: PHP
- Size: 43.9 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Scalar Values Tools

## Installation ##
To install scalar-values with Composer just run :
```bash
$ composer require ecommit/scalar-values
```## Usage ##
Test if an array contains only scalar values :
```php
use Ecommit\ScalarValues\ScalarValues;$array = ['str1', 2, 3];
if (ScalarValues::containsOnlyScalarValues($array)) { //True
//...
} else {
//...
}$array = ['str1', ['tab'], 3];
if (ScalarValues::containsOnlyScalarValues($array)) { //False
//...
} else {
//...
}
```Returns the input array after deleting all non-scalar values (on root):
```php
use Ecommit\ScalarValues\ScalarValues;$array = ['str1', ['tab'], 3];
$newArray = ScalarValues::filterScalarValues($array); //[0 => 'str1', 2 => 3]
```## License ##
This librairy is under the MIT license. See the complete license in *LICENSE* file.