Re: [SMARTY] Array - get the key from the value

From: Date: Thu, 05 Dec 2002 15:33:04 +0000
Subject: Re: [SMARTY] Array - get the key from the value
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-6654@lists.php.net to get a copy of this message
you need to assign a variable (or array for multi select) that is used for the selected elements. $smarty->assign('selected',$_POST['select_me']); <select name=select_me> {html_options values=$MyTypes.ids output=$MyTypes.types selected=$selected} </select> On Thu, 2002-12-05 at 08:54, philippe.morange@ca-indosuez.com wrote: > Hi, > I've searched the mailing-list archive without finding info on this. > > Here is my problem: > I have an associative array that looks like this: > $MyTypes = array( 'ids' => $ids, > 'types' => $types ); > > ids types > ----------------------------- > 0 switched > 1 terminated > > > And I want to make a dropdown menu with this: > {html_options values=$MyTypes.ids output=$MyTypes.types selected=???} > > The problem is that I want a certain option to be selected. > How can I get the key from the value? > Here, knowing "terminated", I want to get the "1"... which is the value of > "terminated"... > > Thanks, > Philippe. -- Monte Ohrt <monte@ispi.net>

« previous php.smarty.general (#6654) next »