Re: Array with $ problem

From: Date: Fri, 13 Oct 2000 19:46:31 +0000
Subject: Re: Array with $ problem
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-20071@lists.php.net to get a copy of this message
You can do it, but you'll need to use "eval()". It would look a little like this... <? $middle = " \"TYPE\"=>\"select\", \"NAME\"=>\"sex\", \"SIZE\"=>1, \"VALUE\"=>\"NULL\", \"OPTIONS\"=>array( \"NULL\"=>\"Please Select\", \"M\"=>\"Male\", \"F\"=>\"Female\"), \"ValidationErrorMessage\"=>\"Must select sex\" "; eval("\$aArray = array($middle);"); $subscription->AddInput($aArray); ?> JRB LeagueOffice.com Fantasy Sports ------------------------------------------------------- http://www.leagueoffice.com as cool as fantasy sports get... ------------------------------------------------------- "A. Gent" <agent_@yahoo.com> wrote: > > Hi, > > Could someone help me please to tell me, what's wrong > with passing value to an array with a variable? > > Example: > > This works fine: > > $subscription->AddInput(array( > "TYPE"=>"select", > "NAME"=>"sex", > "ValidateRegularExpression"=>"^[M | F]+$", > "SIZE"=>1, > "VALUE"=>"NULL", > "OPTIONS"=>array( > "NULL"=>"Please Select", > "M"=>"Male", > "F"=>"Female" > ), > "ValidationErrorMessage"=>"Must select sex" > )); > > > This does not: > > $middle = " > "TYPE"=>"select", > "NAME"=>"sex", > "SIZE"=>1, > "VALUE"=>"NULL", > "OPTIONS"=>array( > "NULL"=>"Please Select", > "M"=>"Male", > "F"=>"Female""; > > > $subscription->AddInput(array( > $middle > ), > "ValidationErrorMessage"=>"Must select sex" > )); > > > Could someone tell me please, how could I feed in > $middle? > > Thank you. > > Art > > > __________________________________________________ > Do You Yahoo!? > Get Yahoo! Mail - Free email you can access from anywhere! > http://mail.yahoo.com/ > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net > > -- ls

« previous php.general (#20071) next »