# RFC proposal.

- Thread: https://externals.io/message/88670
- Original archive: https://news-web.php.net/php.internals/88670
- Started by somebody anon on 2015-10-04T22:10:25+00:00
- Messages: 3
- 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

---

## #88670 — somebody anon — 2015-10-04T22:10:25+00:00

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

Hi PHP community. I am a developer with few years experience in PHP and now
want to propose some addition to default "filesystem" extension. There's
money_format and number_format functions to format money and number values
in human-readable format, but there is not any "size_format" function that
does the same - reformat an integer that holds size in bytes in well-formed
string representing size in one of "big" units like MB or GB. So I can
implement function to do this with following interface:
> size_format($format, $bytes, $unit = null)
that will format size like printf with taking in accoun using unit and
multiplier (1k or 1024).
So, I wait for responses. Thanks for attention.

---

## #88689 — Rowan Collins — 2015-10-05T22:42:08+00:00

URL: https://externals.io/message/88670#88689 · In reply to: #88670

>Hi PHP community. I am a developer with few years experience in PHP and
>now
>want to propose some addition to default "filesystem" extension.
>There's
>money_format and number_format functions to format money and number
>values
>in human-readable format, but there is not any "size_format" function
>that
>does the same - reformat an integer that holds size in bytes in
>well-formed
>string representing size in one of "big" units like MB or GB. So I can
>implement function to do this with following interface:
> > […]
>that will format size like printf with taking in accoun using unit and
>multiplier (1k or 1024).
>So, I wait for responses. Thanks for attention.

An interesting idea. Do you have any idea of the values $format and $unit would accept? Would it handle both decimal-based GB etc and binary-based GiB etc [1]?

What about other units that can be scaled in the same way, like metres? Would it make more sense to make it a unit-formatting function or library - and if so, does it need to be in core, or could it just be a lightweight Composer dependency people could grab when they needed it? 

[1] https://en.m.wikipedia.org/wiki/Binary_prefix

Regards,
-- 
Rowan Collins
[IMSoP]

---

## #88695 — Remi Collet — 2015-10-06T12:21:04+00:00

URL: https://externals.io/message/88670#88695 · In reply to: #88670

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Le 05/10/2015 00:10, somebody anon a écrit :

"someone.wanted.to.be.unknown@gmail.com"

Can't be serious...

> Hi PHP community. I am a developer with few years experience in PHP
> and now want to propose some addition to default "filesystem"
> extension. There's money_format and number_format functions to
> format money and number values in human-readable format, but there
> is not any "size_format" function that does the same - reformat an
> integer that holds size in bytes in well-formed string representing
> size in one of "big" units like MB or GB. So I can implement
> function to do this with following interface:
> > […]
> that will format size like printf with taking in accoun using unit
> and multiplier (1k or 1024). So, I wait for responses. Thanks for
> attention.
> 

Don't see any benefit.
Different locales will need different output (US=KiB, Fr=Kio)



Remi.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iEYEARECAAYFAlYTvLAACgkQYUppBSnxahghugCfZzYhBzAaoHjSS4TiwYtO2Zom
oP0AoKC/vAjcQ6f4/p+LDxa3EWoQ+I8J
=V6lZ
-----END PGP SIGNATURE
