Title: foreach() error when using php code   array
Last modified: August 19, 2016

---

# foreach() error when using php code array

 *  Resolved [Mattz](https://wordpress.org/support/users/mattz/)
 * (@mattz)
 * [18 years ago](https://wordpress.org/support/topic/foreach-error-when-using-php-code-array/)
 * I’m using some code and include a config file that holds an array.
 * I every time get an error on the following foreach() and I can’t get rid of it.
 * Am I using an not allowed WP-variable ?
 *     ```
       function renderTLDList()
       {
       	global $domainInfo;
       	?>
       	<select name="tld" size="1">
       	<?
       	foreach($domainInfo as $tld => $attribs)
       	{
       		print "<option value=\"".$tld."\"";
       		if($_POST['tld'] == $tld)
       			print " selected";
       		print ">".$tld."</option>\n";
       	}
       	?>
       	</select>
       	<?
       }
       ```
   
 * Is there a reason for this specific error ?

The topic ‘foreach() error when using php code array’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 0 replies
 * 1 participant
 * Last reply from: [Mattz](https://wordpress.org/support/users/mattz/)
 * Last activity: [18 years ago](https://wordpress.org/support/topic/foreach-error-when-using-php-code-array/)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
