The Symfony Polyfill / Intl Grapheme Component
Warning: You are browsing the documentation for Symfony 2.x, which is no longer maintained.
Read the updated version of this page for Symfony 7.1 (the current stable version).
This component provides a partial, native PHP implementation of the
grapheme_*
functions to users who run PHP versions without theintl
extension.
Installation
1
$ composer require symfony/polyfill-intl-grapheme
Alternatively, you can clone the https://github.com/symfony/polyfill-intl-grapheme repository.
Note
If you install this component outside of a Symfony application, you must
require the vendor/autoload.php
file in your code to enable the class
autoloading mechanism provided by Composer. Read
this article for more details.
Usage
Once this component is installed in your application, you can use the following constants and functions, no matter if the PHP intl extension is installed or not in your server.
Provided Constants
GRAPHEME_EXTR_COUNT
(value =0
)GRAPHEME_EXTR_MAXBYTES
(value =1
)GRAPHEME_EXTR_MAXCHARS
(value =2
)
Provided Functions
- grapheme_extract
- grapheme_stripos
- grapheme_stristr
- grapheme_strlen
- grapheme_strpos
- grapheme_strripos
- grapheme_strrpos
- grapheme_strstr
- grapheme_substr
See also
The polyfill-intl-icu and polyfill-intl-normalizer components provide polyfills for other classes and functions related to the Intl PHP extension.