php - If a key dont exist in array how can I ignore the error -


i need array. run web based game need give values short description. works no problem long key exists in array, if theres key user has not in array outputs undefined offset errors. there keys wont in array, how can ignore them , not print errors?

$storage_values = array(35000 => "använde sin list och besegrade ahmaroth",                          71503 => "avslutade uppgiften att dräpa 250 vargar",                          56431 => "avslutade uppgiften att dräpa 300 drakar",                          , alot more);  $storage = $db->query("select `key` user_storage userid = 69")->fetch();   <? if (array_key_exists($storage['key'], $storages)): ?>  <? foreach($db->query("select `key`, `date` user_storage user_id = 69") $row): ?>  <tr> <td>date</td> <td><?=$storages[$row['key']]?></td> </tr>  <? endforeach ?> <? endif ?> 

now if theres key in user_storage not exist in array offset error, how can ignore them, , print out ones exist in array?

i have tried adding @ before $storages[$row['key']], removes offset error still print out empty <td> element

i hope understand , in advance.

with like

if(isset($storages[$row['key']])){ ?>    <tr>    <td>date</td>    <td><?=$storages[$row['key']]?></td>    </tr> <?php } 

Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -