cakephp/cakephp — comment on commit b75c414bbb175f6317d59fa7f8170597b10ec878
File:  line 0
By bar:

This produces a notice if the cookie value is an empty string, I think this should be tested before the first string character. And also, the function should always return an array, not a string if $ret is null. Something like this:

```php
function __explode($string) {
$array = array();
if (!empty($string[0]) && ($string[0] === '{' || $string[0] === '[') && function_exists('json_decode')) {
$ret = json_decode($string, true);
return ($ret != null) ? $ret : $array;
}
foreach (explode(',', $string) as $pair) {
$key = explode('|', $pair);
if (!isset($key[1])) {
return $key[0];
}
$array[$key[0]] = $key[1];
}
return $array;
}
```