Nightfirecat / RealmEye-API

An easy way to access your character data via RealmEye.
MIT License
13 stars 7 forks source link

PHP Notice is raised for undefined offsets #13

Closed Nightfirecat closed 8 years ago

Nightfirecat commented 9 years ago

When trying to get dyes, if the character has no dyes, PHP will raise a notice regarding the array index not being set. Ex: https://github.com/Nightfirecat/RealmEye-API/blob/master/0.2/index.php#L164

Solution would be to change from this structure:

$var = ($temp = $array[0]) ? $temp : "";

to the following:

if (!isset($array[0])) {
    $array[0] = "";
}
$var = $array[0];

I feel this can be written more succinctly (eg. only write $array[0] once), but don't know how I'd do that offhand.

Nightfirecat commented 9 years ago

Looks like the only other occurrence is at L166.

Also happens at: