The trick that i did was :
if (is_array($mytax)){
if (in_array($taxonomy->name, $mytax)) $stax[] = $taxonomy;
}else{
$stax[] = '';
}
Thank god this is not Java and it’s just PHP :P, it works so far i added types no errors what so ever.
ps: Trevor’s Net solution is awesome, and Jay August as well but instead of null just add an empty string.