181 questions
0
votes
1
answer
105
views
"Variable variable" syntax
This is a question related to getting Drupal CCK fields (just in case that happens to change anything).
I have several Drupal CCK fields with similar names. They have the same name with a number at ...
1
vote
6
answers
414
views
PHP - Variable variables or array for variable inside for()
I have this code that generates an HTML table with php:
<?php
include("numbers2.php");
echo '<table border="1">';
echo '<tr>';
for ($i = 1; $i <= 9; $i++) {
if($a1_pos_txt !== ...
0
votes
1
answer
94
views
Is there any case in which PHP's variable variables make a solution clearer? [duplicate]
Possible Duplicate:
what's an actual use of variable variables?
Is there any case in which PHP's variable variables make a solution clearer?
E.g. this:
$a = 'hello';
$$a = 'hello, world!';
...
0
votes
1
answer
168
views
Howto make a var. name with a var. in C/C++?
I have some vars live:
int foo1;
int foo2;
..
and I want to reach them from:
for (int i = 1;i<=2;i++)
{
// howto get foo1 and foo2?
}
how to get them?
EDIT, end what when it will be no int ...
4
votes
2
answers
5k
views
Access Variable variables with an object
I don't really know how to decribe this problem, so I'm sorry if the title is a bit unclear.
I got an object with array fields. I got the name of these fields stored in a variable and I want to reach ...
8
votes
7
answers
7k
views
How to check if a string can be used as a variable name in PHP?
In PHP one can use variable variables...
For example...
class obj { }
$fieldName = "Surname";
$object = new obj();
$object->Name = "John";
$object->$fieldName = "Doe";
echo "{$object->Name}...
3
votes
3
answers
473
views
Variable variables: when useful? [duplicate]
Possible Duplicate:
What's an actual use of variable variables?
OK, this question may look a little bit point-whoreish, but I'd really like to know: when are variable variables useful? I haved ...
9
votes
7
answers
2k
views
What's an actual use of variable variables?
Variable variables seem pretty cool, but I can't think of a scenario where one would actually use them in a production environment. What would such a scenario be? How were they used?
-1
votes
5
answers
347
views
Iterate a series of variables which have incremented numeric suffixes
There are 10 variables. say $var1, $var2, $var3, $var4,....$var10
and a $count variable. what I am looking for is if all variables are set then $count = 10+1 or if 9 variables only set then $count=9+1 ...
1
vote
1
answer
1k
views
Change PHP evaluation of $$k[0] from ${$k[0]} to ${$k}[0]
I have a piece of code here that does not work despite me using a $$ on it to treat the string as a variable:
<? foreach (KOHANA::config('list.amenities_forms') as $k => $v) : ?>
<div ...
3
votes
5
answers
5k
views
Variable Variables Pointing to Arrays or Nested Objects
Is it possible to create a variable variable pointing to an array or to nested objects? The php docs specifically say you cannot point to SuperGlobals but its unclear (to me at least) if this applies ...
6
votes
4
answers
553
views
Javascript's equivalent to PHP's $$varName [duplicate]
Possible Duplicate:
How to access javascript variable value by creating another variable via concatenation?
In PHP I can have:
$theVariable = "bigToe";
$bigToe = "is broken";
such that:
echo "my ...
566
votes
19
answers
282k
views
How do I create variable variables?
I know that some other languages, such as PHP, support a concept of "variable variable names" - that is, the contents of a string can be used as part of a variable name.
I heard that this is ...
0
votes
3
answers
930
views
How can I access methods based on strings in an array?
Hello!
I'm not even sure if this is possible, but hopefully it is in Java. I know I've done it in PHP by using variable variables and accessing a variable dynamically, but I read this isn't possible ...
5
votes
8
answers
3k
views
When to use a variable variable in PHP?
I've been developing in PHP for a while now, and I still have not had a task where I've had to use variable variables. Can anyone give me examples where using them is a good idea ? Or were they ...
6
votes
8
answers
8k
views
Variable variable class extensions in PHP--is it possible?
Is something like the following possible in PHP?
$blah = 'foo1';
class foo2 extends $blah {
//...
}
class foo1 {
//...
}
This gives an error.
I want to dynamically set $blah so I can ...