graham23s Posted July 24, 2007 Share Posted July 24, 2007 Hi Guys, i have an array with users heights like this: $height_array =array("5'0" (152 cm)", "5'1" (155 cm)", "5'2" (157 cm)"); because of the ' and " its not working properly i have escaped them: $height_array =array("5\'0\" (152 cm)", "5\'1\" (155 cm)", "5\'2\" (157 cm)"); is this valid to do that or is there another wya i can do it? thanks guys Graham Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted July 24, 2007 Share Posted July 24, 2007 Thats probably the way you're going to have to do it, or, if this is just for output, you could use the HTML entity: " for the double quotes and: ' for the singles. Although you dont need to escape the single quotes if you are surrounding your string in doubles. Quote Link to comment Share on other sites More sharing options...
graham23s Posted July 24, 2007 Author Share Posted July 24, 2007 Hi GR, it's basically an array so i can foreach it to display back to the user what he/she has selected: <?php ######################################################################### foreach ($height_array as $value) { echo "<option Value=\"{$value}\""; if ($value == $hair) { echo 'SELECTED'; } echo ">{$value}</option>"; } ######################################################################### ?> kinda thing thnaks for the input mate Graham Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted July 24, 2007 Share Posted July 24, 2007 Ok, well since you're making it the value of an html element, i'd go for using the html entities. Otherwise, the browser will get confused, since you surround the value in quotes and it finds other quotes. Quote Link to comment Share on other sites More sharing options...
graham23s Posted July 24, 2007 Author Share Posted July 24, 2007 nice one gr that's what i'll do. thanks for the help mate Graham Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.