如何找到第一个字符是否为下划线?

I tried this

foreach ($categories as $category) {
  if( $category[0] === '_'  ) {
    $option .= '<option>'.$category->name.'</option>';
  }
}

But gives me

Fatal error: Cannot use object of type WP_Term as array

I tried to use implode()

foreach ($categories as $category) {
  $string = implode($category);
  if( $category[0] === '_'  ) {
    $option .= '<option>'.$category->name.'</option>';
  }
}

But gives me

Warning: implode(): Argument must be an array

Fatal error: Cannot use object of type WP_Term as array

UPDATE

var_dump($categories);


array(1) { 
    [5]=> object(WP_Term)#999 (16) {
        ["term_id"]=> int(1) 
        ["name"]=> string(13) "Uncategorized" 
        ["slug"]=> string(13) 
        "uncategorized" 
        ["term_group"]=> int(0) 
        ["term_taxonomy_id"]=> int(1) 
        ["taxonomy"]=> string(8) "category" 
        ["description"]=> string(0) "" 
        ["parent"]=> int(0) 
        ["count"]=> int(9) 
        ["filter"]=> string(3) "raw" 
        ["cat_ID"]=> int(1) 
        ["category_count"]=> int(9) 
        ["category_description"]=> string(0) "" 
        ["cat_name"]=> string(13) "Uncategorized" 
        ["category_nicename"]=> string(13) "uncategorized" 
        ["category_parent"]=> int(0) 
    } 
}

Try this

foreach ($categories as $category) {
  if($category->name[0] == '_'){
    $option .= '<option>'.$category->name.'</option>';
  }
}