- Contains Array, String and Time helper utilities.
- Base encoding - UTF-8
- PSR-4 auto loading standard compatible.
- PHP version >= 5.4.
- MBString PHP extension.
- OpenSSL PHP extension.
- Slugify library
The preferred way to install is through Composer. Run this command to install the latest stable version:
$ composer require misantron/php-utils
or add
"misantron/php-utils": "dev-master"
to the require section of your composer.json.
use Utility\UArray;
use Utility\UString;
use Utility\UTime;
$array = [
['name' => 'Alex', 'age' => 25],
['name' => 'Sara', 'age' => 21],
['name' => 'John', 'age' => 28]
];
$string = '..C’est du français !';
$date1 = new \DateTime('2015-02-26 13:05');
$date2 = new \DateTime('2015-02-26 22:16');
$result1 = UArray::extractColumn($array, 'age');
$result2 = UString::slug($string);
$result3 = UTime::secondsDiff($date1, $date2);
var_dump($result1, $result2, $result3);
[25, 21, 28];
'c-est-du-francais';
33060;