{"id":25498270,"url":"https://github.com/dvlpr1996/php-string-helpers","last_synced_at":"2025-11-11T03:30:18.880Z","repository":{"id":63681634,"uuid":"569860908","full_name":"dvlpr1996/php-string-helpers","owner":"dvlpr1996","description":"some useful php string helpers","archived":false,"fork":false,"pushed_at":"2024-05-13T07:40:34.000Z","size":95,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-05T07:15:42.875Z","etag":null,"topics":["php","php-helper","php-library","php-string","php-string-helper","php8","string","string-helper","string-utilities"],"latest_commit_sha":null,"homepage":"https://github.com/dvlpr1996/php-string-helpers/wiki","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dvlpr1996.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2022-11-23T19:30:39.000Z","updated_at":"2024-05-13T07:38:44.000Z","dependencies_parsed_at":"2023-09-29T12:03:16.365Z","dependency_job_id":null,"html_url":"https://github.com/dvlpr1996/php-string-helpers","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dvlpr1996%2Fphp-string-helpers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dvlpr1996%2Fphp-string-helpers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dvlpr1996%2Fphp-string-helpers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dvlpr1996%2Fphp-string-helpers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dvlpr1996","download_url":"https://codeload.github.com/dvlpr1996/php-string-helpers/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239587269,"owners_count":19663892,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["php","php-helper","php-library","php-string","php-string-helper","php8","string","string-helper","string-utilities"],"created_at":"2025-02-19T02:41:57.796Z","updated_at":"2025-11-11T03:30:18.816Z","avatar_url":"https://github.com/dvlpr1996.png","language":"PHP","readme":"# Helpful Set Of Php String Helper Functions Utilities Class\n\n\n[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/dvlpr1996/php-string-helpers?style=flat)](https://packagist.org/packages/dvlpr1996/php-string-helpers)\n[![Total Downloads](https://img.shields.io/packagist/dt/dvlpr1996/php-string-helpers)](https://packagist.org/packages/dvlpr1996/php-string-helpers)\n\nAll function helpers will be enabled by default (if those functions haven't already been defined).\nalso you can use them as utilities class.\n\n## Requirements\n\n- PHP 8.1 or higher\n\n## Installation\n\nYou can install the package via composer:\n\n```bash\ncomposer require dvlpr1996/php-string-helpers\n```\n\n## StrUtility usage as static methods\n\nyou can use String helper methods as static so usage like the following:\nFirst Using The StrUtility Class:\n\n```php\nuse dvlpr1996\\PhpStringHelpers\\Facade\\StrUtility;\n```\n\n\u003cbr\u003e\n\n- change words to camel case\n\n```php\nStrUtility::toCamelCase(string $words): string\n```\n\n- change words to pascal case\n\n```php\nStrUtility::toPascalCase(string $words): string\n```\n\n- change words to kebab case\n\n```php    \nStrUtility::toKebabCase(string $words): string\n```\n\n- change words to title case\n\n```php     \nStrUtility::toTitleCase(string $words): string\n```\n\n- change words to constant case | foo bar baz change to FOO_BAR_BAZ\n\n```php     \nStrUtility::toConstant(string $words): string\n```\n\n- change words to snake case\n\n```php     \nStrUtility::toSnakeCase(string $words): string  \n```\n\n- change words to path case | foo bar baz change to foo/bar/baz\n\n```php   \nStrUtility::toPathCase(string $words): string\n```\n\n- change words to ada case | foo bar change to Foo_Bar\n\n```php     \nStrUtility::toAdaCase(string $words): string\n```\n\n- change words to dot notation case | foo bar change to foo.bar\n\n```php     \nStrUtility::dotNotation(string $words): string  \n```\n\n- wrapper for htmlspecialchars()\n\n```php   \nStrUtility::entitiesWrapper($data): string\n```\n\n- change string to slug\n\n```php     \nStrUtility::toSlug(string $string): string\n```\n\n- remove all blanks\n\n```php     \nStrUtility::rmAllBlanks(string $string): string     \n```\n\n- return alternate string if string param is null\n\n```php\nStrUtility::alternate(?string $string, string $alternate = null): string    \n```\n\n- translation methods, for using this method you should create a wrapper function \nfor example \n\n```php\nfunction \u003cyour_wrapper_function_name\u003e(string $key, string $alternative = '', string $dirName = 'en')\n{\n    $BASE_PATH = // base (root) path of your project\n\n    $translatePath = StrUtility::translatePath($BASE_PATH, $dirName);\n    return StrUtility::translate($translatePath . $key, $alternative);\n}\n```\n\n\u003c your_wrapper_function_name\u003e('app.title') reference to lang/en/app.php and title array key in app.php\nfile app.php must only return associative array.\nthis translation methods only work for one level\n\n```php\nStrUtility::translate(string $key, string $alternative = ''): string|array\n```\n\n- wrap given string with wrapper param\n\n```php\nStrUtility::wrapper(int|string $string, int|string $wrapper = '*'): string\n```\n\n- return path of file\n\n```php\nStrUtility::filePath(string $path, string $pathExtension = 'php'): string\n```\n\n- generate unique pin numbers between 4 digit and 12 digit\n\n```php\nStrUtility::generatePin(int $length = 4): int\n```\n\n- clean and safe given string data\n\n```php\nStrUtility::clearString(string $data): string\n```\n\n- return only string and remove other characters\n\n```php\nStrUtility::pureString(string $data): string\n```\n\n- generate random string\n\n```php\nStrUtility::randomChar(int $size = 5): string  \n```\n\n- generate random hexadecimal color\n\n```php\nStrUtility::randomHex(): string\n```\n\n- generate random rgb color\n\n```php\nStrUtility::randomRgb(): string\n```\n\n- Remove all types of links\n\n```php\nStrUtility::rmLink(string $string): string\n```\n\n- limit character based on $length and replace theme with ...\n\n```php\nStrUtility::limitChar(string|int $string, int $length): string\n```\n\n- generate unique id numbers\n\n```php\nStrUtility::generateId(string|int $prefix ='',string|int $suffix ='',bool $moreEntropy = false): string   \n```\n\n- remove all numbers\n\n\n```php\nStrUtility::rmNumbers(string $string): string   \n```\n\n- remove all characters\n\n```php\nStrUtility::rmCharacters(string $string): string\n```\n\n- remove all extra blanks\n\n```php\nStrUtility::rmExtraBlank(string $string): string \n```\n\n- convert hex color to rgb color\n\n```php\nStrUtility::hexToRgb(string $color): ?string \n```\n\n- convert rgb color to hex color\n\n```php\nStrUtility::rgbToHex(string $color): ?string\n```\n\n- generate \\\u003ca\\\u003e tag link\n\n```php\nStrUtility::generateAnchor(string|int $content, string $href): string\n```\n\n- return encoding of string . wrapper for mb_detect_encoding()\n\n```php\nStrUtility::getEncoding(string $string): string\n```\n\n```php\nStrUtility::isUtf8(string|array $string): bool\n```\n\n- remove duplicate words\n\n```php\nStrUtility::rmDuplicateWords(string $string): string\n```\n\n- remove characters from right side based on $num param\n\n```php\nStrUtility::rmRightChar(string $words, int $num): string\n```\n\n- remove characters from left side based on $num param\n\n```php\nStrUtility::rmLeftChar(string $words, int $num): string\n```\n\n- remove characters from both side based on $num param\n\n```php\nStrUtility::rmBothSideChar(string $words, int $num): string\n```\n\n- find whether the type of a data is json\n\n```php\nStrUtility::isJson(mixed $data): bool\n```\n\n- Checks whether the string contains the specified value or not\n\n```php\nStrUtility::isContains(string $string, string $search, bool $caseSensitive = false): bool\n```\n\n- Checks whether the string starts with the specified value \u003c$search\u003e or not\n\n```php\nStrUtility::isStartWith(string $string, string $search, bool $caseSensitive = false): bool\n```\n\n- return the last word\n\n```php\nStrUtility::lastWord(string $string): string\n```\n\n- return the first word\n\n```php\nStrUtility::firstWord(string $string): string\n```\n\n- return the first number\n\n```php\nStrUtility::getFirstNumbers(string $string): string\n```\n\n- return the last number\n\n```php\nStrUtility::getLastNumbers(string $string): string\n```\n\n```php\nStrUtility::rmBeginningNumbers(string $string): string\n```\n\n```php\nStrUtility::rmEndingNumbers(string $string): string\n```\n\n```php\nStrUtility::convertToUtf8(string $string): string|bool\n```\n\n- incrementing the numbers of the end of the string\n\n```php\nStrUtility::incrementBy(string $string, ?string $separator = null): string\n```\n\n- decrementing the numbers of the end of the string\n\n```php\nStrUtility::decrementBy(string $string, ?string $separator = null): string\n```\n\n- remove last word from given string \n\n```php\nStrUtility::rmLastWord(string $string): string\n```\n\n- remove first word from given string\n\n```php\nStrUtility::rmFirstWord(string $string): string\n```\n\n- find whether the type of a given string is slug\n\n```php\nStrUtility::is_slug(string $slug): bool\n```\n\n- find whether the type of a given ip is valid ipv4\n\n```php\nStrUtility::is_ipv4(string $ip): bool\n```\n\n- find whether the type of a given ip is valid ipv6\n\n```php\nStrUtility::is_ipv6(string $ip): bool\n```\n\n- Deletes the words before the given $search word\n\n```php\nStrUtility::after(string $string, string $search): string\n```\n\n- Deletes the words after the given $search word\n\n```php\nStrUtility::before(string $string, string $search): string\n```\n\n```php\nStrUtility::hasSpace(string $string): bool\n```\n\n```php\nStrUtility::isEmail(string $email): bool\n```\n\n```php\nStrUtility::detectCase(string $word): string\n```\n\n```php\nStrUtility::isLowerCase(string $word): bool\n```\n\n```php\nStrUtility::isUpperCase(string $word): bool\n```\n\n```php\nStrUtility::isTitleCase(string $word): bool\n```\n\n```php\nStrUtility::isSnakeCase(string $word): bool\n```\n\n```php\nStrUtility::validateUserName(string $userName, int $min = 3, int $max = 20): bool\n```\n\n```php\nStrUtility::humanFileSize(int $size, string $type = 'KB'): string\n```\n\n## StrUtility usage as helper functions\n\nString helper functions are global so usage like the following:\n\n```php\ndecrementBy(string $string, ?string $separator = null): string\n```\n## StrUtility usage as object\n\n```php\nuse PhpStringHelpers\\utility\\StrUtility;\n\n$string = new StrUtility;\n\n$string-\u003etoConstant('foo bar baz');\n```\n\n## Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.\n\n## issues\n\nIf you discover any issues, please using the issue tracker.\n\n## Credits\n\n-   [Nima jahan bakhshian](https://github.com/dvlpr1996)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdvlpr1996%2Fphp-string-helpers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdvlpr1996%2Fphp-string-helpers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdvlpr1996%2Fphp-string-helpers/lists"}