FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Variable variables?
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Variable variables? [message #182270 is a reply to message #182268] Sat, 27 July 2013 03:27 Go to previous messageGo to previous message
Scott Johnson is currently offline  Scott Johnson
Messages: 196
Registered: January 2012
Karma:
Senior Member
On 7/26/2013 1:04 PM, Luuk wrote:
> On 26-07-2013 04:56, Scott Johnson wrote:
>> I have a situation which I 'think' I need to use variable variables and
>> not sure how to go about it.
>>
>>
>> I have several <select multiple> elements on a search form with their
>> names created dynamically and the options created dynamically.
>>
>> $parent holds the name such as "Women", "Mens" etc..
>> $c_id holds category_id and is sent off as the 'value' of the option.
>>
>> This form is self calling and an array is created for the multiple
>> option selected.
>>
>> Women => array([0]=>20,[1]=>21,...)
>> Mens => array([0]=>32,[1]=>35,...)
>>
>> I am using in_array() to check returned posted values against an id.
>>
>> How do I reference that array by using the value of $parent.
>>
>> if $parent is 'Women' I need to reference the array 'Women'
>>
>> Here is a nutshell of the algorithm.
>>
>> foreach($parent_ary as $parent) {
>> echo "<select {$parent}[] multiple>";
>> foreach($category_ary as $c_id=>$category) {
>> if(in_array($c_id, array of posted value)) {
>> // Create select option
>> } else {
>> // Create regular option
>> }
>> }
>> echo "</select>";
>> }
>>
>> I hope this makes sense and yes I did RTM but could not transpose what
>> they where explaining to what I need to do.
>>
>> Thanks
>> Scotty
>
> This will return 'test':
> $a="test"; $b="a"; print ${$b};
>
> so, if $parent="Woman", then ${$parent} should refer to the $Woman[],
> and if $parent="Mens" then ${$parent} should refer to $Mens[]
>
>
>
>
>

Ahhhh.

I saw that in the manual but could not wrap my head around it. Thanks
very much.

Scotty
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Query with PHP and MySql
Next Topic: Dynamically changing links in a web page menu when a link is clicked
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Thu Nov 28 09:14:42 GMT 2024

Total time taken to generate the page: 0.07344 seconds