c_shelswell Posted January 25, 2007 Share Posted January 25, 2007 Hi i'm trying to make an array to spit out a load of different countrys to populate a select box i've got:[code]$bizArray = array( '<option value="AI">Anguilla </option>', '<option value="AR">Argentina </option>', '<option value="AU">Australia </option>', '<option value="AT">Austria </option>', '<option value="BE">Belgium </option>',[/code]problem is it's only returning the country names and knocking off the <option value> bits.Anyway to stop this?Cheers Link to comment https://forums.phpfreaks.com/topic/35655-array-missing-bits/ Share on other sites More sharing options...
c_shelswell Posted January 25, 2007 Author Share Posted January 25, 2007 seek and ye shall find sorry might have been a bit quick to post up here.[code]$bizArray = array(htmlspecialchars("<option value='AI'>Anguilla </option>"),htmlspecialchars('<option value="AR">Argentina </option>'));[/codeseems to work. Will take a while to type it all out mind you. Is there better way?[/code] Link to comment https://forums.phpfreaks.com/topic/35655-array-missing-bits/#findComment-168895 Share on other sites More sharing options...
kenrbnsn Posted January 25, 2007 Share Posted January 25, 2007 How are you using this array? Please post the code that uses it.This code works fine:[code]<?php$bizArray = array( '<option value="AI">Anguilla </option>', '<option value="AR">Argentina </option>', '<option value="AU">Australia </option>', '<option value="AT">Austria </option>', '<option value="BE">Belgium </option>'); echo '<form>';echo 'Country: <select name="country">';echo '<option value=""></option>';for ($i=0;$i<count($bizArray);$i++) echo $bizArray[$i];echo '</select>';echo '</form>';?>[/code]Ken Link to comment https://forums.phpfreaks.com/topic/35655-array-missing-bits/#findComment-168896 Share on other sites More sharing options...
c_shelswell Posted January 25, 2007 Author Share Posted January 25, 2007 basically i'm storing a customers details in the database but when they come to purchase they get a chance to amend their details. I want my option box to default to their country so i was going to do this:[code]foreach ($bundles as $key => $value){ $id = $value['media_id']; $title = $value['title']; echo "\t<option value='$id'"; if ($media_id == $id){echo "selected";} echo "/>".$title."</option>\n";}[/code]this is a bit of code i used elsewhere in my project and as i was putting it here i just realised my array won't work with the <option> tags already in there going to have to change it. Link to comment https://forums.phpfreaks.com/topic/35655-array-missing-bits/#findComment-168898 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.