title: Cannot use object of type WP_Term as array
body: <p>Given these categories:</p>
  
  <pre><code>_Hello
  _1979
  </code></pre>
  
  <p>I am running this:</p>
  
  <pre><code>    $option = " ";
      $categories = get_categories( array( 'hide_empty'  =&gt; 0 ) ); 
      foreach ( $categories as $category ) {
        // Since string indexing is zero-based, we want to check if
        // the first char is an underscore and
        // the second character is a digit
        if( $category[0] === '_' &amp;&amp; ctype_digit( $category[1] ) ) {
          // chop off the leading underscore
          $category = substr( $category, 1 );
        } else {
          $option .= '&lt;option&gt;'.$category-&gt;name.'&lt;/option&gt;';
        }
      }
      return $option;
  </code></pre>
  
  <p>But it returns:</p>
  
  <blockquote>
    <p>Cannot use object of type WP_Term as array</p>
  </blockquote>
  
  <p>Basically first I check if a <code>Category</code> has an <code>underscore</code> and if so I check if it starts with a <code>string</code> or a <code>number</code>. And if it's a <code>string</code>, then I output the <code>&lt;option&gt;</code></p>