kennynguyeenx / vietnamese-text
Provide some Vietnamese string handling and manipulating functions.
Installs: 17 229
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- php: >=7.0
- ext-intl: *
- ext-mbstring: *
Requires (Dev)
- phpunit/php-code-coverage: ^4.0.4
- phpunit/phpunit: ~4.8|~5.2
This package is auto-updated.
Last update: 2025-03-16 19:30:51 UTC
README
Provide some Vietnamese string handling and manipulating functions
Features
- Filter a Vietnamese string
- Make a Vietnamese string uppercase
- Make a Vietnamese string lowercase
- Get Vietnamese string length
- Reverse a Vietnamese string
- Convert a Vietnamese string to an array
- Make a Vietnamese string's first character uppercase
- Convert a Vietnamese string to a Latin string
- No external dependencies.
- PSR-4 compatible.
- Compatible with PHP >= PHP 7.
Installation
-
You can download vietnamese-text through https://github.com/kennynguyeenx/vietnamese-text.
-
vietnamese-text requires the Internationalization extension and Multibyte String extension from PHP.
-
Typically you can use the configure option
--enable-intl --enable-mbstring
while compiling PHP. More information can be found in the PHP documentation.
Usage
Filter a Vietnamese string:
use Kennynguyeenx\VietnameseText\VietnameseText; $vietnameseText = new VietnameseText(); echo $vietnameseText->filter(' áo ' . PHP_EOL . 'dài '); // áo dài
Make a Vietnamese string lowercase:
use Kennynguyeenx\VietnameseText\VietnameseText; $vietnameseText = new VietnameseText(); echo $vietnameseText->strToLowerCase('XIN CHÀO CÁC BẠN'); // xin chào các bạn
Make a Vietnamese string uppercase:
use Kennynguyeenx\VietnameseText\VietnameseText; $vietnameseText = new VietnameseText(); echo $vietnameseText->strToUpperCase('Xin Chào Các Bạn'); // XIN CHÀO CÁC BẠN
Get Vietnamese string length:
use Kennynguyeenx\VietnameseText\VietnameseText; $vietnameseText = new VietnameseText(); echo $vietnameseText->strLen('Xin Chào Các Bạn'); // 16
Reverse a Vietnamese string:
use Kennynguyeenx\VietnameseText\VietnameseText; $vietnameseText = new VietnameseText(); echo $vietnameseText->strRev('Xin Chào'); // oàhC niX
Convert a Vietnamese string to an array:
use Kennynguyeenx\VietnameseText\VietnameseText; $vietnameseText = new VietnameseText(); var_dump($vietnameseText->strSplit('xin chào')); /* array(8) { [0]=> string(1) "x" [1]=> string(1) "i" [2]=> string(1) "n" [3]=> string(1) " " [4]=> string(1) "c" [5]=> string(1) "h" [6]=> string(2) "à" [7]=> string(1) "o" } */
Make a Vietnamese string's first character uppercase:
use Kennynguyeenx\VietnameseText\VietnameseText; $vietnameseText = new VietnameseText(); echo $vietnameseText->upperCaseFirst('đại biểu'); // Đại biểu
Convert a Vietnamese string to a Latin string:
use Kennynguyeenx\VietnameseText\VietnameseText; $vietnameseText = new VietnameseText(); echo $vietnameseText->convertToLatin('đại biểu'); // dai bieu