PHPackages                             hilalahmad/string-util - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. hilalahmad/string-util

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

hilalahmad/string-util
======================

php-string-util is a versatile PHP library designed to simplify and enhance string manipulation tasks in your PHP projects. Whether you're working on web development, data processing, or any other application requiring robust string handling, this utility provides a comprehensive set of functions.

1.0.0(2y ago)09MITPHPPHP ^7.2 | ^8.0

Since Nov 16Pushed 2y ago1 watchersCompare

[ Source](https://github.com/hilalahmad0101/php-string-util)[ Packagist](https://packagist.org/packages/hilalahmad/string-util)[ RSS](/packages/hilalahmad-string-util/feed)WikiDiscussions master Synced yesterday

READMEChangelog (1)DependenciesVersions (2)Used By (0)

string-util PHP Package
=======================

[](#string-util-php-package)

 *string-util is a versatile PHP library designed to simplify and enhance string manipulation tasks in your PHP projects. Whether you're working on web development, data processing, or any other application requiring robust string handling, this utility provides a comprehensive set of functions.*

 [ ![GitHub issues](https://camo.githubusercontent.com/ac50f4e9442bed459adce07c893f846cf522e560e908e8e37c4ec303429cf575/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f68696c616c61686d6164303130312f7068702d737472696e672d7574696c) ](https://github.com/hilalahmad0101/php-string-util/issues) [ ![GitHub stars](https://camo.githubusercontent.com/85323627a19df57c5e497ec25f43d0772775d1e2ad49fe561f39fd71efa823e2/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f68696c616c61686d6164303130312f7068702d737472696e672d7574696c) ](https://github.com/hilalahmad0101/php-string-util/stargazers) [ ![Total Downloads](https://camo.githubusercontent.com/ae963b86ed6ab43a294151f49fa6e944c3f89a1b16b8960535b399a55846bdf0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f68696c616c61686d6164303130312f7068702d737472696e672d7574696c) ](https://packagist.org/packages/hilalahmad0101/php-string-util) [ ![License](https://camo.githubusercontent.com/151d05b36ff98458669f913144f2b6778760e180174dcf771b06c88bc4175be1/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f68696c616c61686d6164303130312f7068702d737472696e672d7574696c) ](https://github.com/hilalahmad0101/php-string-util/blob/main/LICENSE)

###### 20+ function you can use it in your project make your project string better

[](#20-function-you-can-use-it-in-your-project-make-your-project-string-better)

Installation
------------

[](#installation)

You can install this package using Composer, a popular PHP package manager:

```
composer require hilalahmad/string-util
```

Basic Usage
-----------

[](#basic-usage)

Here's an example of how to use the string utils package:

```
use Hilalahmad\StringUtil\StringUtil;

$stringToReverse = "Hello, World!";
$reversedString = StringUtil::reverseString($stringToReverse);
echo "Reversed String: $reversedString\n";

$substring = StringUtil::extractSubstring($stringToReverse, 0, 5);
echo "Substring: $substring\n";

$charToCount = "l";
$occurrences = StringUtil::countOccurrences($stringToReverse, $charToCount);
echo "Occurrences of '$charToCount': $occurrences\n";

$startsWithResult = AdvancedStringUtil::startsWith($stringToReplace, "The");
echo "Starts with 'The': " . ($startsWithResult ? "Yes" : "No") . "\n";

$endsWithResult = AdvancedStringUtil::endsWith($stringToReplace, "dog.");
echo "Ends with 'dog.': " . ($endsWithResult ? "Yes" : "No") . "\n";

$titleCaseString = AdvancedStringUtil::toTitleCase("this is a title");
echo "Title Case: $titleCaseString\n";

$strippedString = AdvancedStringUtil::stripTags("This is bold text.");
echo "Stripped Tags: $strippedString\n";

$randomString = AdvancedStringUtil::generateRandomString(8);
echo "Random String: $randomString\n";

$needle = "brown";
$pos = AdvancedStringUtil::strposIgnoreCase($stringToReplace, $needle);
echo "Position of '$needle': $pos\n";

$palindromeString = "A man, a plan, a canal: Panama";
$isPalindrome = AdvancedStringUtil::isPalindrome($palindromeString);
echo "Is Palindrome: " . ($isPalindrome ? "Yes" : "No") . "\n";

$paddedString = AdvancedStringUtil::padString("Hello", 10, '*');
echo "Padded String: $paddedString\n";

$base64Encoded = AdvancedStringUtil::base64Encode("Hello, World!");
echo "Base64 Encoded: $base64Encoded\n";

$base64Decoded = AdvancedStringUtil::base64Decode($base64Encoded);
echo "Base64 Decoded: $base64Decoded\n";

$camelCaseString = AdvancedStringUtil::toCamelCase("convert_this_string");
echo "CamelCase String: $camelCaseString\n";

$longString = "This is a long string that needs truncation.";
$truncatedString = AdvancedStringUtil::truncateString($longString, 20);
echo "Truncated String: $truncatedString\n";

$stringWithNewlines = "This is a\nstring with\nnewlines.";
$htmlString = AdvancedStringUtil::nl2br($stringWithNewlines);
echo "HTML Line Breaks: $htmlString\n";

$multiReplaceString = "Replace spaces with underscores and dots with dashes.";
$searchReplaceArray = [' ' => '_', '.' => '-'];
$replacedString = AdvancedStringUtil::multiReplace($multiReplaceString, $searchReplaceArray);
echo "Multi-Replaced String: $replacedString\n";

$slugString = "Convert This String to a URL-friendly Slug";
$slug = AdvancedStringUtil::toSlug($slugString);
echo "Slug: $slug\n";

$reversedWordsString = AdvancedStringUtil::reverseWords("Reverse these words!");
echo "Reversed Words: $reversedWordsString\n";

$leetspeakString = AdvancedStringUtil::toLeetspeak("Leetspeak is fun!");
echo "Leetspeak: $leetspeakString\n";

$wordCount = AdvancedStringUtil::countWords("Count the words in this sentence.");
echo "Word Count: $wordCount\n";

$stringWithEmails = "Contact us at info@example.com or support@company.com";
$emails = AdvancedStringUtil::extractEmails($stringWithEmails);
echo "Extracted Emails: " . implode(', ', $emails) . "\n";

$urlSlugString = "Convert this string to a URL-friendly slug!";
$urlSlug = AdvancedStringUtil::toUrlSlugFormat($urlSlugString);
echo "URL Slug: $urlSlug\n";

// Example usage:
$htmlEntitiesString = "Encode & decode entities!";
$encodedHtml = AdvancedStringUtil::encodeHtmlEntities($htmlEntitiesString);
echo "Encoded HTML Entities: $encodedHtml\n";

$decodedHtml = AdvancedStringUtil::decodeHtmlEntities($encodedHtml);
echo "Decoded HTML Entities: $decodedHtml\n";

$hashtagsString = "Check out #PHP and #WebDevelopment!";
$hashtags = AdvancedStringUtil::extractHashtags($hashtagsString);
echo "Extracted Hashtags: " . implode(', ', $hashtags) . "\n";

$asciiString = "Convert to ASCII üñïçødë";
$asciiRepresentation = AdvancedStringUtil::toAscii($asciiString);
echo "ASCII Representation: $asciiRepresentation\n";

$caseSwapString = "SwapCase";
$swappedCase = AdvancedStringUtil::swapCase($caseSwapString);
echo "Swapped Case: $swappedCase\n";

$duplicatesString = "Remove duplicate characters";
$noDuplicates = AdvancedStringUtil::removeDuplicates($duplicatesString);
echo "Remove Duplicates: $noDuplicates\n";

$morseCodeString = "Hello, World!";
$morseCode = AdvancedStringUtil::toMorseCode($morseCodeString);
echo "Morse Code: $morseCode\n";

$soundexString = "Soundex";
$soundexKey = AdvancedStringUtil::toSoundex($soundexString);
echo "Soundex Key: $soundexKey\n";

$delimiterReplaceString = "Replace spaces with delimiter";
$delimiterReplaced = AdvancedStringUtil::replaceSpacesWithDelimiter($delimiterReplaceString);
echo "Replace Spaces: $delimiterReplaced\n";

$nonAlphanumericString = "Remove special characters!@#";
$removedNonAlphanumeric = AdvancedStringUtil::removeNonAlphanumeric($nonAlphanumericString);
echo "Remove Non-Alphanumeric: $removedNonAlphanumeric\n";
```

Contribution
------------

[](#contribution)

If you'd like to contribute to this package or report issues, please check the [ Github repo](https://github.com/fullstack124/php-string-util/issues) for more details.

License
-------

[](#license)

This package is open-source and is licensed under the MIT License.

###  Health Score

22

—

LowBetter than 21% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

960d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8130aa2a0353184f190feb106a6c11f57afa8872ec9e15e75b782d9e03dc5bde?d=identicon)[hilal ahmad](/maintainers/hilal%20ahmad)

---

Top Contributors

[![hilalahmad0101](https://avatars.githubusercontent.com/u/115874624?v=4)](https://github.com/hilalahmad0101 "hilalahmad0101 (3 commits)")

### Embed Badge

![Health badge](/badges/hilalahmad-string-util/health.svg)

```
[![Health](https://phpackages.com/badges/hilalahmad-string-util/health.svg)](https://phpackages.com/packages/hilalahmad-string-util)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
