<?php foreach ($categories_arr as $cat_key => $cat_value) { ?>
<option value="<?php echo $cat_key+1; ?>"<?php echo (in_array($cat_key, [$list_selection])) ? 'selected="selected"' : ""; ?>><?php echo $cat_value['category_name']; ?></option>
<?php } ?>
return $result ?: position($val1, $val2, $val3);
можно ведь так?