Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #10219

Re: Variable variables?

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!us.feeder.erje.net!news2.arglkargh.de!news.mixmin.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Date Fri, 26 Jul 2013 22:04:53 +0200
From Luuk <luuk@invalid.lan>
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130620 Thunderbird/17.0.7
MIME-Version 1.0
Newsgroups comp.lang.php
Subject Re: Variable variables?
References <ksso5i$u2t$1@dont-email.me>
In-Reply-To <ksso5i$u2t$1@dont-email.me>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
Message-ID <3c1bca-p81.ln1@luuk.invalid.lan> (permalink)
Lines 53
NNTP-Posting-Host 2001:980:9089:1:8966:4a16:a859:b517
X-Trace 1374869402 news.xs4all.nl 16008 [2001:980:9089:1:8966:4a16:a859:b517]:56550
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.php:10219

Show key headers only | View raw


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[]




Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Variable variables? Scott Johnson <noonehome@chalupasworld.com> - 2013-07-25 19:56 -0700
  Re: Variable variables? Jerry Stuckle <jstucklex@attglobal.net> - 2013-07-26 06:56 -0400
    Re: Variable variables? Scott Johnson <noonehome@chalupasworld.com> - 2013-07-26 12:39 -0700
      Re: Variable variables? Jerry Stuckle <jstucklex@attglobal.net> - 2013-07-27 09:48 -0400
        Re: Variable variables? Tim Streater <timstreater@greenbee.net> - 2013-07-27 15:45 +0100
          Re: Variable variables? The Natural Philosopher <tnp@invalid.invalid> - 2013-07-27 15:46 +0100
            Re: Variable variables? Tim Streater <timstreater@greenbee.net> - 2013-07-27 15:53 +0100
  Re: Variable variables? Luuk <luuk@invalid.lan> - 2013-07-26 22:04 +0200
    Re: Variable variables? Scott Johnson <noonehome@chalupasworld.com> - 2013-07-26 20:27 -0700
  Re: Variable variables? Christoph Michael Becker <cmbecker69@arcor.de> - 2013-07-26 22:17 +0200
    Re: Variable variables? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-07-27 09:37 +0200

csiph-web