{"id":16409530,"url":"https://github.com/pointybeard/helpers-functions-strings","last_synced_at":"2026-04-17T14:37:31.334Z","repository":{"id":57043222,"uuid":"185728167","full_name":"pointybeard/helpers-functions-strings","owner":"pointybeard","description":"A collection of functions for manipulating strings","archived":false,"fork":false,"pushed_at":"2020-04-09T23:26:01.000Z","size":12,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-26T14:00:00.152Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pointybeard.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-05-09T04:49:56.000Z","updated_at":"2020-04-09T23:25:58.000Z","dependencies_parsed_at":"2022-08-23T23:40:17.443Z","dependency_job_id":null,"html_url":"https://github.com/pointybeard/helpers-functions-strings","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/pointybeard/helpers-functions-strings","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pointybeard%2Fhelpers-functions-strings","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pointybeard%2Fhelpers-functions-strings/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pointybeard%2Fhelpers-functions-strings/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pointybeard%2Fhelpers-functions-strings/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pointybeard","download_url":"https://codeload.github.com/pointybeard/helpers-functions-strings/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pointybeard%2Fhelpers-functions-strings/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":284719042,"owners_count":27052182,"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","status":"online","status_checked_at":"2025-11-16T02:00:05.974Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2024-10-11T06:20:18.448Z","updated_at":"2025-11-16T14:04:05.924Z","avatar_url":"https://github.com/pointybeard.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PHP Helpers: String Functions\n\n-   Version: v1.1.3\n-   Date: April 10 2020\n-   [Release notes](https://github.com/pointybeard/helpers-functions-strings/blob/master/CHANGELOG.md)\n-   [GitHub repository](https://github.com/pointybeard/helpers-functions-strings)\n\nA collection of functions for manipulating strings\n\n## Installation\n\nThis library is installed via [Composer](http://getcomposer.org/). To install, use `composer require pointybeard/helpers-functions-strings` or add `\"pointybeard/helpers-functions-strings\": \"~1.1.0\"` to your `composer.json` file.\n\nAnd run composer to update your dependencies:\n\n    $ curl -s http://getcomposer.org/installer | php\n    $ php composer.phar update\n\n### Requirements\n\nThere are no particuar requirements for this library other than PHP 7.2 or greater.\n\nTo include all the [PHP Helpers](https://github.com/pointybeard/helpers) packages on your project, use `composer require pointybeard/helpers` or add `\"pointybeard/helpers\": \"~1.2.0\"` to your composer file.\n\n## Usage\n\nThis library is a collection convenience function for common tasks relating to string manipulation. They are included by the vendor autoloader automatically. The functions have a namespace of `pointybeard\\Helpers\\Functions\\Strings`\n\nThe following functions are provided:\n\n-   `utf8_wordwrap`\n-   `utf8_wordwrap_array`\n-   `type_sensitive_strval`\n-   `mb_str_pad`\n-   `replace_placeholders_in_string`\n-   `random_string`\n-   `random_unique_classname`\n-   `encode_ampersands`\n\nExample usage:\n\n```php\n\u003c?php\n\ndeclare(strict_types=1);\n\ninclude __DIR__.'/vendor/autoload.php';\n\nuse pointybeard\\Helpers\\Functions\\Strings;\n\nvar_dump(Strings\\utf8_wordwrap(\n    'Some long string that we want to wrap at 20 characeters',\n    20,\n    PHP_EOL,\n    true\n));\n// string(55) \"Some long string\n// that we want to wrap\n// at 20 characeters\"\n\nvar_dump(Strings\\utf8_wordwrap_array(\n    'Some long string that we want to wrap at 20 characeters',\n    20,\n    PHP_EOL,\n    true\n));\n// array(3) {\n//   [0] =\u003e string(16) \"Some long string\"\n//   [1] =\u003e string(20) \"that we want to wrap\"\n//   [2] =\u003e string(17) \"at 20 characeters\"\n// }\n\nvar_dump(Strings\\type_sensitive_strval(true));\n// string(4) \"true\"\n//\nvar_dump(Strings\\type_sensitive_strval([1, 2, 3, 4]));\n// string(5) \"array\"\n\nvar_dump(Strings\\type_sensitive_strval(new \\stdClass()));\n// string(6) \"object\"\n\nvar_dump(Strings\\mb_str_pad('Apple', 11, 'àèò', STR_PAD_LEFT, 'UTF-8'));\n// string(17) \"àèòàèòApple\"\n\nvar_dump(Strings\\mb_str_pad('Banana', 11, 'àèò', STR_PAD_RIGHT, 'UTF-8'));\n// string(16) \"Bananaàèòàè\"\n\nvar_dump(Strings\\mb_str_pad('Pear', 11, 'àèò', STR_PAD_BOTH, 'UTF-8'));\n// string(18) \"àèòPearàèòà\"\n\nvar_dump(Strings\\replace_placeholders_in_string(\n    ['FIRSTNAME', 'LASTNAME', 'EMAILADDRESS'],\n    ['Sarah', 'Smith', 'sarah.smith@example.com'],\n    'My name is {{FIRSTNAME}} {{LASTNAME}}. Contact me at {{EMAILADDRESS}}.'\n));\n// string(62) \"My name is Sarah Smith. Contact me at sarah.smith@example.com.\"\n\nvar_dump(Strings\\replace_placeholders_in_string(\n    ['ONE', 'TWO', 'THREE', 'FOUR'],\n    ['apple', 'banana', 'orange', 'banana'],\n    '[ONE], [TWO], [THREE], [NOPE]',\n    true,\n    '[',\n    ']'\n));\n// string(23) \"apple, banana, orange, \"\n\nvar_dump(Strings\\random_string(15));\n// string(15) \"cTAPWAi2EOCop2N\"\n\ntry {\n    var_dump(Strings\\random_string(8, '@[^-]@i'));\n} catch (Error $ex) {\n    echo 'Error generating random string. returned: '.$ex-\u003egetMessage().PHP_EOL;\n}\n// Error generating random string. returned: minimal characters generated. filter '@[^-]@i' might be too restrictive\n\nvar_dump(Strings\\random_unique_classname('test', '\\\\MyApp'));\n// string(36) \"testOIXwzi9D6bAbvy5y9QYoayS2kabbBh56\"\n\nvar_dump(Strings\\encode_ampersands(\"10 \u0026lt; 15 \u0026 5 \u0026gt; 1. \u0026#x1234;\"));\n// string(35) \"10 \u0026lt; 15 \u0026amp; 5 \u0026gt; 1. \u0026#x1234;\"\n\nvar_dump(Strings\\encode_ampersands('Apples \u0026 bananàs and pickles \u0026amp; cheese.'));\n// string(47) \"Apples \u0026amp; bananàs and pickles \u0026amp; cheese.\"\n```\n\n## Support\n\nIf you believe you have found a bug, please report it using the [GitHub issue tracker](https://github.com/pointybeard/helpers-functions-strings/issues),\nor better yet, fork the library and submit a pull request.\n\n## Contributing\n\nWe encourage you to contribute to this project. Please check out the [Contributing documentation](https://github.com/pointybeard/helpers-functions-strings/blob/master/CONTRIBUTING.md) for guidelines about how to get involved.\n\n## License\n\n\"PHP Helpers: String Functions\" is released under the [MIT License](http://www.opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpointybeard%2Fhelpers-functions-strings","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpointybeard%2Fhelpers-functions-strings","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpointybeard%2Fhelpers-functions-strings/lists"}