{"id":36373528,"url":"https://github.com/php-filter/string-filter","last_synced_at":"2026-01-11T14:03:30.536Z","repository":{"id":56375722,"uuid":"311968946","full_name":"php-filter/string-filter","owner":"php-filter","description":"PHP String Filter is a library to perform character string transformation using a chain. You can use the most popular filters built into PHP and additional ones added by the author and community.","archived":false,"fork":false,"pushed_at":"2024-11-06T18:48:43.000Z","size":146,"stargazers_count":4,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-10-05T11:47:45.982Z","etag":null,"topics":["chain","filters","php","string","transform"],"latest_commit_sha":null,"homepage":"","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/php-filter.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-11-11T12:48:07.000Z","updated_at":"2022-02-21T12:40:26.000Z","dependencies_parsed_at":"2022-08-15T17:31:36.168Z","dependency_job_id":null,"html_url":"https://github.com/php-filter/string-filter","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/php-filter/string-filter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-filter%2Fstring-filter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-filter%2Fstring-filter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-filter%2Fstring-filter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-filter%2Fstring-filter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/php-filter","download_url":"https://codeload.github.com/php-filter/string-filter/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-filter%2Fstring-filter/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28306985,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-11T11:18:18.743Z","status":"ssl_error","status_checked_at":"2026-01-11T11:07:56.842Z","response_time":60,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["chain","filters","php","string","transform"],"created_at":"2026-01-11T14:03:29.879Z","updated_at":"2026-01-11T14:03:30.530Z","avatar_url":"https://github.com/php-filter.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PHP String Filters\n[![Minimum PHP Version](https://img.shields.io/badge/php-%3E%3D%207.3-8892BF.svg)](https://php.net/)\n![Tests](https://github.com/php-filter/string-filter/workflows/Testing/badge.svg?=1.x)\n[![Latest Version](https://img.shields.io/github/tag/php-filter/string-filter.svg)](https://github.com/php-filter/string-filter/releases)\n![GitHub](https://img.shields.io/github/license/php-filter/string-filter.svg)\n\nPHP String Filter is a library to perform character string transformation using a chain. You can use the most popular filters built into PHP and additional ones added by the author and community.\n\nSupport the following **input data** types: **string, integer, float, boolean, null and object** (must have a __toString method)\nSupport the following **output data** types: string, **int, float, bool and stringOrNull, intOrNull, floatOrNull**\n\n## Installation\n\nInstall in your projects:\n\n```bash\ncomposer require php-filter/string\n```\n\nAnd use:\n\n```php+HTML\n$filter = Filter::of('/_big_ball_of_mud_/')\n            -\u003ereplace('/', '')\n            -\u003ereplace('_', '')\n            -\u003eupperWords();\n\n$filter-\u003evalueString(); // 'Big Ball Of Mud'\n```\n\n**Filter list:**\n\n| Filter                                    | Input                                           | Output                                          |\n| ----------------------------------------- | ----------------------------------------------- | ----------------------------------------------- |\n| alnum()                                   | `LLeMs!ZaF_F3dEX 4`                             | `LLeMsZaFF3dEX4`                                |\n| alnumWith('_')                            | `LLeMs!$%ZaF_F3dEX 4`                           | `LLeMsZaF_F3dEX4`                               |\n| append('Smith')                           | `John`                                          | `JohnSmith`                                     |\n| camelize()                                | `primary-getallgroups-sys`                      | `primaryGetallgroupsSys`                        |\n| extractBetween('`\u003cdiv\u003e`',  '`\u003c/div\u003e`')    | `\u003cdiv\u003etest\u003c/div\u003e`                               | `test`                                          |\n| htmlSpecialCharsDecode()                  | `\u0026lt;a href=\u0026quot;test\u0026quot;\u0026gt;Test\u0026lt;/a\u0026gt;` | `\u003ca href=\"test\"\u003eTest\u003c/a\u003e`                       |\n| htmlSpecialChars()                        | `\u003ca href=\"test\"\u003eTest\u003c/a\u003e`                       | `\u0026lt;a href=\u0026quot;test\u0026quot;\u0026gt;Test\u0026lt;/a\u0026gt;` |\n| letter()                                  | `girl_123`                                      | `girl`                                          |\n| letterWith('_')                           | `girl_123!`                                     | `girl_`                                         |\n| limit(4)                                  | `this is`                                       | `this`                                          |\n| lowerFirst()                              | `Big Ben`                                       | `big Ben`                                       |\n| lower()                                   | `Lucy Brown`                                    | `lucy brown`                                    |\n| numeric()                                 | `a123`                                          | `123`                                           |\n| numericWith('.')                          | `10.31 zl`                                      | `10.31`                                         |\n| prepend('John ')                          | `Smith`                                         | `JohnSmith`                                     |\n| removeMultipleSpaces()                    | `Replacing     multiple spaces`                 | `Replacing multiple spaces`                     |\n| remove(' Up Front')                       | `Big Design Up Front`                           | `Big Design`                                    |\n| repeat(3)                                 | `test`                                          | `testtesttest`                                  |\n| replaceRegex('/[^a-zA-Z0-9]/', '')        | `Big-Design-Up-Front`                           | `BigDesignUpFront`                              |\n| replace('Design Up Front', 'Ball Of Mud') | `Big Design Up Front`                           | `Big Ball Of Mud`                               |\n| reverse()                                 | `test`                                          | `tset`                                          |\n| shuffle()                                 | `test`                                          | `tset`                                          |\n| stripHtml('`\u003cb\u003e`')                        | `\u003cu\u003e\u003cb\u003etest\u003c/b\u003e\u003c/u\u003e`                            | `dsadsa`                                        |\n| strPadLeft(12, '0');                      | `2/10/2020`                                     | `0002/10/2020`                                  |\n| strPadRight(12, '0');                     | `0002/10/2`                                     | `0002/10/2000`                                  |\n| substr(0, 4);                             | `test 123`                                      | `test`                                          |\n| trimLeft('.')                             | ` .test `                                       | `test `                                         |\n| trimRight('.')                            | ` test. `                                       | ` test`                                         |\n| trim()                                    | ` test `                                        | `test`                                          |\n| upperFirst()                              | `lucy`                                          | `Lucy`                                          |\n| upper()                                   | `lucy Brown`                                    | `LUCY BROWN`                                    |\n| upperWords()                              | `lucy lue`                                      | `Lucy Lue`                                      |\n| wordWrap(3, '`\u003c/br\u003e`')                    | `Big Design Up Front`                           | `Big\u003c/br\u003eDesign\u003c/br\u003eUp\u003c/br\u003eFront`               |\n\n**Filter example:**\n\nFor a list of filters and more examples of their application, see [unit tests](https://github.com/php-filter/string-filter/tree/main/tests/Filters).\n\n```php\n\n$filter = Filter::of('/_big_ball_of_mud_/')\n            -\u003ereplace('/', '')\n            -\u003ereplace('_', '')\n            -\u003eupperWords();\n\n$filter-\u003evalueString(); // 'Big Ball Of Mud'\n```\n\n**An example of a reusable filter grouping:**\n\n```php\n$groupFilters = function ($value) {\n\treturn Filter::of($value)-\u003etrim()-\u003eupperFirst()-\u003eappend('.');\n};\n\n$filter = $groupFilters(' wikipedia is a free online encyclopedia');\n\n$filter-\u003evalueString(); // 'Wikipedia is a free online encyclopedia.'\n\n```\n\n**Example value output:**\n\n```php\n$filter = Filter::of(10.00)-\u003evalue()-\u003eint() // 10\n$filter = Filter::of(10.00)-\u003evalue()-\u003estring() // '10.00'\n$filter = Filter::of(true)-\u003evalue()-\u003estring() // 'true'\n$filter = Filter::of(null)-\u003evalue()-\u003eintOrNull() // null\n```\n\n**Example of value information:**\n\n```php\n$info = Filter::of('wikipedia is a free online encyclopedia, created and edited by by volunteers')-\u003einfo();\n\n$info-\u003elength(); // 76\n$info-\u003ewordsCount(); // 12\n$info-\u003ephaseCount('ee'); // 2\n```\n\n## Roadmap\n\n- [x] Description of all filters with examples\n- [ ] Add more filters\n- [ ] You tell me...\n\n## License\n\nPHP String Filters is released under the MIT License. See the bundled LICENSE file for details.\n\n## Author\n\n[@Miłosz Karolczyk](https://www.linkedin.com/in/milosz-karolczyk/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphp-filter%2Fstring-filter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphp-filter%2Fstring-filter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphp-filter%2Fstring-filter/lists"}