Title: Loop through array
Last modified: August 20, 2016

---

# Loop through array

 *  Resolved [Archie Makuwa](https://wordpress.org/support/users/archie22is/)
 * (@archie22is)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/loop-through-array/)
 * Hi guys,
 * I have the following code which returns the followig array:
 *     ```
       5 =>
           object(stdClass)[14]
             public 'term_id' => string '62' (length=2)
             public 'name' => string 'IT & Telecommunications' (length=27)
             public 'slug' => string 'it-and-telecommunications' (length=25)
             public 'term_group' => string '0' (length=1)
             public 'term_taxonomy_id' => string '151' (length=3)
             public 'taxonomy' => string 'services' (length=8)
             public 'description' => string '' (length=0)
             public 'parent' => string '0' (length=1)
             public 'count' => string '0' (length=1)
       ```
   
 * However whenever I loop through the returned array list using the following code:
 *     ```
       $mycateg = get_terms( 'services', array(
       							'parent' => 0,
       							'oderby' => 'name',
       							'hide_empty' => 0
       							)
       						);
       					echo "test";
   
       					foreach ($mycateg as $categ) {
       						echo $mycateg->name;
       					}
       ```
   
 * I get no output at all – only a null. what is the correct way to create output?

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [vtxyzzy](https://wordpress.org/support/users/vtxyzzy/)
 * (@vtxyzzy)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/loop-through-array/#post-3243652)
 * I think you need to change this:
 *     ```
       echo $mycateg->name;
       ```
   
 * to this:
 *     ```
       echo $categ->name;
       ```
   
 *  Thread Starter [Archie Makuwa](https://wordpress.org/support/users/archie22is/)
 * (@archie22is)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/loop-through-array/#post-3243653)
 * Thank you!!
 * What a silly mistake… #lack of coffee
 *  Thread Starter [Archie Makuwa](https://wordpress.org/support/users/archie22is/)
 * (@archie22is)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/loop-through-array/#post-3243691)
 * #Resolved

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Loop through array’ is closed to new replies.

## Tags

 * [categories](https://wordpress.org/support/topic-tag/categories/)
 * [child category](https://wordpress.org/support/topic-tag/child-category/)
 * [loop](https://wordpress.org/support/topic-tag/loop/)
 * [taxonomy](https://wordpress.org/support/topic-tag/taxonomy/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 3 replies
 * 2 participants
 * Last reply from: [Archie Makuwa](https://wordpress.org/support/users/archie22is/)
 * Last activity: [13 years, 6 months ago](https://wordpress.org/support/topic/loop-through-array/#post-3243691)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
