Hello,
I started to edit the array_column function to accept the fourth
parameter to group the similar results
The current behavior is when you have multiple elements share the same
key, it will be overwritten.
let's assume that we have the following.
<?php
$array = [
['id' => 1, 'name' => 'hassan'],
['id' => 2, 'name' => 'sara'],
['id' => 3, 'name' => 'selim'],
['id' => 4, 'name' => 'chris'],
['id' => 5, 'name' => 'sara'],
];
when we use array_column with this the output will be
print_r(array_column($array, null, 'name'));
Array
(
[hassan] => Array
(
[id] => 1
[name] => hassan
)
[sara] => Array
(
[id] => 5
[name] => sara
)
[selim] => Array
(
[id] => 3
[name] => selim
)
[chris] => Array
(
[id] => 4
[name] => chris
)
)
I'd added a fourth parameter to array_column to group the results in
an indexed array to group all the similar elements, so we can use :
print_r(array_column($array, null, 'name', true));
Array
(
[hassan] => Array
(
[0] => Array
(
[id] => 1
[name] => hassan
)
)
[sara] => Array
(
[0] => Array
(
[id] => 2
[name] => sara
)
[1] => Array
(
[id] => 5
[name] => sara
)
)
[selim] => Array
(
[0] => Array
(
[id] => 3
[name] => selim
)
)
[chris] => Array
(
[0] => Array
(
[id] => 4
[name] => chris
)
)
)
not sure if we need to implement this as a new function
array_column_group
or we can keep the fourth optional parameter.
however, I have an issue in creating an account on the wiki so I can
not create an RFC.
it keeps giving me this error That wasn't the answer we were expecting
no matter the email/user name I use
PR number: https://github.com/php/php-src/pull/7698
however, I have an issue in creating an account on the wiki so I can
not create an RFC.it keeps giving me this error
That wasn't the answer we were expecting
no matter the email/user name I use
You need to enter the address of this mailing list in the last input
field. :)
--
Christoph M. Becker
Hello Christoph, Thanks for your reply, I already created the account
and now waiting for the account confirmation. Thanks a lot.
however, I have an issue in creating an account on the wiki so I can
not create an RFC.it keeps giving me this error
That wasn't the answer we were expecting
no matter the email/user name I useYou need to enter the address of this mailing list in the last input
field. :)--
Christoph M. Becker
Hello Christoph, Thanks for your reply, I already created the account
and now waiting for the account confirmation. Thanks a lot.
RFC karma granted. Best of luck! :)
Christoph
Thanks a lot for your support.
Hello Christoph, Thanks for your reply, I already created the account
and now waiting for the account confirmation. Thanks a lot.RFC karma granted. Best of luck! :)
Christoph
Hello Christoph, does there any way to update my username from
7snovic
to hassan
?
Thanks a lot for your support.
Hello Christoph, Thanks for your reply, I already created the account
and now waiting for the account confirmation. Thanks a lot.RFC karma granted. Best of luck! :)
Christoph
Hello Christoph, does there any way to update my username from
7snovic
tohassan
?
Done.
Also, please note that top posting is frowned upon on the PHP mailing
lists, see
https://github.com/php/php-src/blob/master/docs/mailinglist-rules.md. :)
Christoph