Jump to content

Displaying an array


spires

Recommended Posts

Hi Guys.

 

Does anyone know how to display an array inside a textarea?

 

What i'm trying to do select US state from a drop down menu,

this then refreshes the page, creating an array that holds all of the US states.

 

Then it should display the full list inside a textarea.

 

Example:

http://www.adwordstool.co.uk/test.php

 

If you select 'US State' from the drop down, it should

fill the top right textarea with the full list of states.

 

But, it just says array.

 

Heres some of the code:

<!-- Array -->
if ($alt=='US States'){
$state = array("Alabama, Alaska, Arizona, Arkansas, California, Colorado, Connecticut, Delaware, Florida, Georgia, Hawaii, Idaho, Illinois, Indiana, Iowa, Kansas, Kentucky, Louisiana, Maine, Maryland, Massachusetts, Michigan, Minnesota, Mississippi, Missouri, Montana, Nebraska, Nevada, New Hampshire, New Jersey, New Mexico, New York, North Carolina, North Dakota, Ohio, Oklahoma, Oregon, Pennsylvania, Rhode Island, South Carolina, South Dakota, Tennessee, Texas, Utah, Vermont, Virginia, Washington, West Virginia, Wisconsin, Wyoming");

}


<!-- textarea -->
<textarea name="ad_group" cols="38" rows="8" class="Forms" style="background-color:#FFFFCC" id="ad_group">
<?PHP 
$alt_text_array =  explode(",", $state);
foreach ($alt_text_array as $altText) {
        $altText = trim($altText);
echo $altText; 
}
?>


<!-- DropDown -->
<select name="Alt" onChange="this.form.submit()">
<?PHP 
if ($alt){
echo '<option value="'.$alt.'" selected>'.$alt.'</option>';
echo '<option value="">------------</option>';
echo '<option value="US States">US States</option>';
echo '<option value="US Capitals">US Capitals</option>';
}else{
echo '<option value="" selected>Select Extentions</option>';
echo '<option value="US States">US States</option>';
echo '<option value="US Capitals">US Capitals</option>';
}
?>
</select>	

</textarea>

 

 

Thanks for any help\

 

Cheers

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/100151-displaying-an-array/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.