Welcome Guest, Not a member yet? Register   Sign In
array helper, element function - returns false on empty
#1

[eluser]Unknown[/eluser]
Hi all,

This isn't necessarily a "bug", but rather something I think is being done incorrectly.

In the array_helper.php file, the function element(...) returns FALSE on two conditions:
1. The array element is not set.
2. The array element is set but is empty.

I think #2 should be returned as '' (empty) rather than as FALSE. The reason is that sometimes, an array element is purposely set to be empty, like:
Code:
$name['first'] = 'John';
$name['middle'] = '';
$name['last'] = 'Doe';

So we purposely set middle to be '' and not FALSE. By returning FALSE, we are not describing the array element accurately!

Therefore, my proposed fix is simply:
- On line 44 of array_helper.php, change:
Code:
if ( ! isset($array[$item]) OR $array[$item] == "")
to:
Code:
if ( ! isset($array[$item]))


Michael Huynh




Theme © iAndrew 2016 - Forum software by © MyBB