use Utility\StringUtility; // Convert a string to camel case $camelCaseString = StringUtility::toCamelCase('hello_world'); // Truncate a long string $shortString = StringUtility::truncate('Lorem ipsum dolor sit amet', 10); // Check if a string starts with a certain substring $startsWith = StringUtility::startsWith('Hello, world!', 'Hello');
use Utility\ArrayUtility; // Filter an array by a certain key $filteredArray = ArrayUtility::filterByKey(['name' => 'John', 'age' => 30, 'gender' => 'male'], ['name']); // Merge arrays $mergedArray = ArrayUtility::merge(['name' => 'John', 'age' => 30], ['location' => 'New York']); // Flatten a multi-dimensional array $flattenedArray = ArrayUtility::flatten(['name' => 'John', 'info' => ['age' => 30, 'gender' => 'male']]);In conclusion, PHP Utility is a package library that provides a set of utility classes and functions for common tasks in PHP development. The examples provided above showcase some of the functionalities provided by the String Utility and Array Utility classes, respectively.