# [RFC] [VOTE] mb_str_pad

- Thread: https://externals.io/message/120530
- Original archive: https://news-web.php.net/php.internals/120530
- Started by Niels Dossche on 2023-06-05T17:59:32+00:00
- Messages: 4
- RFC: mb_str_pad (Implemented (PHP 8.3)) — https://externals.io/rfc/mb_str_pad.md
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · RFCs at https://externals.io/rfc.md · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #120530 — Niels Dossche — 2023-06-05T17:59:32+00:00

URL: https://externals.io/message/120530#120530

Hello internals

I'm opening the vote now on my proposal to include `mb_str_pad()` into PHP 8.3.
RFC link: https://wiki.php.net/rfc/mb_str_pad

The vote will last until 2023-06-19 20:00 GMT+2.

Kind regards
Niels

---

## #120532 — Christian Schneider — 2023-06-06T07:12:47+00:00

URL: https://externals.io/message/120530#120532 · In reply to: #120530

Am 05.06.2023 um 19:59 schrieb Niels Dossche <dossche.niels@gmail.com>:
> I'm opening the vote now on my proposal to include `mb_str_pad()` into PHP 8.3.
> RFC link: https://wiki.php.net/rfc/mb_str_pad

I voted "No" because I think it should be grapheme_str_pad instead and I'd like to avoid having both the mb_ and grapheme_ versions which unnecessarily confuses users.

I guess I should have spoken up before but I couldn't think of a use case for padding characters instead of graphemes. Or am I missing something?

- Chris

---

## #120536 — Niels Dossche — 2023-06-06T18:20:14+00:00

URL: https://externals.io/message/120530#120536 · In reply to: #120532

Hi Christian


> Am 05.06.2023 um 19:59 schrieb Niels Dossche <dossche.niels@gmail.com>:
> > […]
> 
> I voted "No" because I think it should be grapheme_str_pad instead and I'd like to avoid having both the mb_ and grapheme_ versions which unnecessarily confuses users.
> 
> I guess I should have spoken up before but I couldn't think of a use case for padding characters instead of graphemes. Or am I missing something?
> 
> - Chris
> 

Thanks for explaining, I appreciate that.

String padding is naturally often associated with display. The use-cases I had in mind are rather more related to data formats, protocols and/or standards. Although a lot of users who hand-rolled their own mb_str_pad misuse it for display purposes, there are use-cases that do indeed use it for the purposes I described above. Some random examples I found using GH code search:
* https://github.com/WPPlugins/estonian-banklinks-for-woocommerce/blob/5f97891cfb43d9bde6017243998a3ab424f43b93/includes/gateways/class-wc-banklink-estcard-gateway.php#L139
* https://github.com/ExaByt3s/fodyo/blob/eefdec7da76c820e90987b32baf2aef5ea8d6ca2/bitrix/modules/sale/lib/tradingplatform/vk/feed/data/converters/product.php#L179
* https://github.com/mbence/csaladsegito/blob/20e639b1865ac2ba6be8fc64f69ba9e6f474ef0f/src/JCSGYK/AdminBundle/Services/ClosingService.php#L381

I heard the grapheme argument two times before, one time on the list and one time on Reddit.
I do think it's primarily a documentation problem. One problem may be though that a non-negligible number of users probably don't read documentation. The fact that this comes up again gives me a little bit of fear whether the function would cause confusion. So I'm keeping my ears open for concerns.

For visual purposes I'm also not sure if a grapheme variant would fully suffice, as it would also require the grapheme to be fixed width. But that's another issue of course.


Kind regards
Niels

---

## #120620 — Niels Dossche — 2023-06-19T18:05:04+00:00

URL: https://externals.io/message/120530#120620 · In reply to: #120530

> Hello internals
> 
> I'm opening the vote now on my proposal to include `mb_str_pad()` into PHP 8.3.
> RFC link: https://wiki.php.net/rfc/mb_str_pad
> 
> The vote will last until 2023-06-19 20:00 GMT+2.
> 
> Kind regards
> Niels

Hi internals

The voting is now closed with 15 yes and 1 no vote.
The RFC is therefore accepted.
Thanks to everyone who voted.

Kind regards
Niels
