# [RFC] Improve array to string conversion

- Thread: https://externals.io/message/80366
- Original archive: https://news-web.php.net/php.internals/80366
- Started by F & N Laupretre on 2015-01-11T13:29:48+00:00
- Messages: 5
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #80366 — F & N Laupretre — 2015-01-11T13:29:48+00:00

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

Hi,

A new RFC for PHP7 : https://wiki.php.net/rfc/array-to-string

Not implemented yet, but the PR is available for comments :
https://github.com/php/php-src/pull/991

Regards

François

---

## #80373 — Stelian Mocanita — 2015-01-11T17:25:23+00:00

URL: https://externals.io/message/80366#80373 · In reply to: #80366

I would vote for the first option and entirely deprecate the array to
string conversion. As far as I can see there is no real world use-case for
it and most of the time it does more harm than good.

Stelian

On Sun, Jan 11, 2015 at 2:29 PM, F & N Laupretre <nf.laupretre@yahoo.fr>
wrote:

> Hi,
>
> A new RFC for PHP7 : https://wiki.php.net/rfc/array-to-string
>
> Not implemented yet, but the PR is available for comments :
> https://github.com/php/php-src/pull/991
>
> Regards
>
> François

---

## #80440 — Derick Rethans — 2015-01-13T12:00:47+00:00

URL: https://externals.io/message/80366#80440 · In reply to: #80366

> Hi,
> 
> A new RFC for PHP7 : https://wiki.php.net/rfc/array-to-string

The voting options are missing in there. They should (probably) be:

- don't change
- 1st alternative
- 2nd alternative

cheers,
Derick

---

## #80441 — F & N Laupretre — 2015-01-13T13:52:08+00:00

URL: https://externals.io/message/80366#80441 · In reply to: #80440

Fixed. Thanks

> -----Message d'origine-----
> De : Derick Rethans [mailto:derick@php.net]
> Envoyé : mardi 13 janvier 2015 13:01
> À : F & N Laupretre
> Cc : internals@lists.php.net
> Objet : Re: [PHP-DEV] [RFC] Improve array to string conversion
> 
> 
> 
> > […]
> 
> The voting options are missing in there. They should (probably) be:
> 
> - don't change
> - 1st alternative
> - 2nd alternative
> 
> cheers,
> Derick

---

## #80840 — Patrick ALLAERT — 2015-01-19T17:42:20+00:00

URL: https://externals.io/message/80366#80840 · In reply to: #80366

Le Sun Jan 11 2015 at 14:30:42, F & N Laupretre <nf.laupretre@yahoo.fr> a
écrit :

> Hi,
>
> A new RFC for PHP7 : https://wiki.php.net/rfc/array-to-string
>
> Not implemented yet, but the PR is available for comments :
> https://github.com/php/php-src/pull/991
>
> Regards
>
> François
>

Just for the record, when I implemented the `E_NOTICE` on that conversion I
received lot of complaints of users using (incorrectly) the `array_diff()`
family which internally compare all sub-elements given their "string"
representation. It means that if you present something for "option 3" you
also have to think about the way those functions will behave (and the
possible BC introduced.

Note the exact same behavior with multi dimensional arrays containing same
/ different content:

// Same sub-array
php > var_dump( array_diff( [['a']], [['a']] ) );
PHP Notice:  Array to string conversion in php shell code on line 1

array(0) {
}

// Different sub-array
php > var_dump( array_diff( [['a']], [['42']] ) );
PHP Notice:  Array to string conversion in php shell code on line 1

array(0) {
}

My 0.02€.

Patrick
