mapleleaf Posted April 14, 2009 Share Posted April 14, 2009 So I need to create a drop down from an array and I want the name id and value to be the location. My code below creates an array but by default the keys are assigned when i create the drop down. I want to assign the key as the the location too. Any ideas? $options = array(); foreach($query->result() as $row) { array_push($options, $row->location); } Appreciated Link to comment https://forums.phpfreaks.com/topic/153979-solved-creating-an-array-where-the-key-and-value-are-the-same/ Share on other sites More sharing options...
gizmola Posted April 14, 2009 Share Posted April 14, 2009 $options = array(); foreach($query->result() as $row) { $options[$row->location] = $row->location; } Link to comment https://forums.phpfreaks.com/topic/153979-solved-creating-an-array-where-the-key-and-value-are-the-same/#findComment-809325 Share on other sites More sharing options...
mapleleaf Posted April 14, 2009 Author Share Posted April 14, 2009 gizmola I wish I had asked sooner. THANKS! Link to comment https://forums.phpfreaks.com/topic/153979-solved-creating-an-array-where-the-key-and-value-are-the-same/#findComment-809327 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.