Voting

: max(one, six)?
(Example: nine)

The Note You're Voting On

yangmeishu at live dot com
4 years ago
Please note that if you use array_column to reset the index, when the index value is null, there will be different results in different PHP versions, examples
<?php

$array
= [
[
'name' =>'Bob',
'house' =>'big',
],
[
'name' =>'Alice',
'house' =>'small',
],
[
'name' =>'Jack',
'house' => null,
],
];
var_dump(array_column($array,null,'house'));

On 5.6.30, 7.0.0, 7.2.0 (not limited to) get the following results
array(3) {
[
"big"]=>
array(
2) {
[
"name"]=>
string(3) "Bob"
["house"]=>
string(3) "big"
}
[
"small"]=>
array(
2) {
[
"name"]=>
string(5) "Alice"
["house"]=>
string(5) "small"
}
[
0]=>
array(
2) {
[
"name"]=>
string(4) "Jack"
["house"]=>
NULL
}
}

The new index, null will be converted to int, and can be incremented according to the previous index, that is, if Alice "house" is also null, then Alice's new index is "0", Jack's new index is "1"

On 7.1.21, 7.2.18, 7.4.8 (not limited to) will get the following results
array(3) {
[
"Big"]=>
array(
2) {
[
"name"]=>
string(3) "Bob"
["house"]=>
string(3) "Big"
}
[
"small"]=>
array(
2) {
[
"name"]=>
string(5) "Alice"
["house"]=>
string(5) "small"
}
[
""]=>
array(
2) {
[
"name"]=>
string(4) "Jack"
["house"]=>
NULL
}
}

The new index null will be converted to an empty string

<< Back to user notes page

To Top