Skip to main content
Filter by
Sorted by
Tagged with
3 votes
1 answer
139 views

Let's say I have an array_1 containing a string which is a name of another array_2. And now I would like to convert the array index into a variable containing the array_2. I have the following working ...
Jimski's user avatar
  • 1,001
1 vote
2 answers
193 views

I need to use a variable variable for defining a lambda function inside of the callback of array_map(). I get an "Undefined variable" WARNING for the variable that I am referencing. ...
plsssineedheeeelp's user avatar
0 votes
0 answers
64 views

I've got a database full of text fields, all of which contain WITHIN them the characters $myvariable. When I retrieve such text field and save it as a php variable, say as $myDBtext, I can definitely ...
Daniel F's user avatar
0 votes
2 answers
319 views

I am trying to override some variables in my PHP file using variable variables, but I am getting unexpected results, where the original value is never overwritten, but where the new variable-variable ...
Brandon McConnell's user avatar
0 votes
3 answers
3k views

I`m trying to build an function that load script on-demand. That is my current code: function loadScript(src, name = null) { var dfd = jQuery.Deferred(); if (name === null) { name = ...
Bruno Natali's user avatar
2 votes
1 answer
704 views

Today I met such a terrible situation. It seems this bug is related to PHP. I'm trying to access to $_SERVER or another super global variables but from string name. This version of implementation is ...
Aaron Yordanyan's user avatar
1 vote
1 answer
92 views

I've been hitting my head on this problem for some time now. I am working on a piece of software that creates a tree from a MySQL result checking for changes between each row to decide where in the ...
Francesco's user avatar
  • 519
0 votes
1 answer
44 views

I'm creating code that creates new user identifications for users, and then adds all their account details to a dictionary and then adds this dictionary to another dictionary of all the accounts. My ...
always-confused's user avatar
0 votes
1 answer
110 views

I just noticed that if you try to put a variable variable into a use list of a closure, it throws a parse error. Example code: foreach ($array as $key => $item) { $$key = $item->something; ...
aborted's user avatar
  • 4,569
-1 votes
1 answer
71 views

How I can use for loop PHP to create same result in $d4_c_d_v as below? Note: $d4_c_d_v must end without comma at the end. $d4_c_d_v = $g_demographics_value_0['id'] .','. $g_demographics_value_1['...
Adam Makowski's user avatar
0 votes
2 answers
152 views

Say I had the variable $foo which has a value of "bar" and I wanted to make a variable variable from it, but also append the string "123" to it, so that the variable name is $bar123. How would I do ...
David Wheatley's user avatar
3 votes
2 answers
413 views

In my code, I want to try fetching $_POST or $_GET variables, and unsetting them as soon as they were requested once. This function returns the method used, which is simple enough. Unfortunately I ...
Dwarf Vader's user avatar
-3 votes
2 answers
81 views

This is quite a stupid question. I want to find out how to increase a number in the end of the variable: $Coffee1 = "black"; $Coffee2 = "brown"; $Coffee3 = "gray"; echo $Coffee1; => black ...
Kivennäisvesi's user avatar
0 votes
2 answers
118 views

Is it possible to split variables that have already been assigned values, and re-piece them back together to hold those same previous values? For Example: URLs.QA.Signin = 'https://qa.test.com' ...
bitShredder's user avatar
1 vote
1 answer
67 views

Let's say I have an array of strings that I use to create variable variables: $var_arr = ["item1", "item2", "item3"]; foreach ($var_arr as $item) { $$item = array(); } Then elsewhere in my code I ...
Troy D's user avatar
  • 401
0 votes
2 answers
701 views

just started to dabble with Javascript so I'm sorry if this is a basic question. I have an array of keys: keys = ['fruits','vegetables','fats','meats'] I want to dynamically create a Map for each of ...
tokatokeari's user avatar
0 votes
1 answer
108 views

I'm trying to do a bit of php magic in one line with instantiating a class, but it seems the parser wont allow me. Example: class Test{ private $foo; public function __construct($value){ ...
Dennis's user avatar
  • 949
0 votes
1 answer
38 views

Is there a way to return a variable variable from a function? This is what I tried: function varvar($num){ $var = "foo".$num; return $$var; } varvar(3); echo $foo3; But nothing prints out. ...
adamdesign's user avatar
0 votes
1 answer
109 views

Before upgrading to PHP 7, I had this code and it returned true var_dump(isset($$_SESSION['payment']) ); var_dump(is_object($$_SESSION['payment'])); var_dump($_SESSION['payment']); // string '...
kurama's user avatar
  • 827
-3 votes
1 answer
2k views

Using R stats, I want to access a variable variable scenario similar to PHP double-dollar-sign technique: http://php.net/manual/en/language.variables.variable.php Specifically, I am looking for a ...
mshaffer's user avatar
  • 1,013
1 vote
1 answer
109 views

I'm beginner of PHP, I found a Warning says: Please note that variable variables cannot be used with PHP's Superglobal arrays within functions or class methods. So, does it mean I can use variable ...
LIU YUE's user avatar
  • 2,097
0 votes
1 answer
410 views

I've set a few variables: $field = "XYZ"; $block_hi = $field."_hi"; $block_lo = $field."_lo"; Then I have an object with properties that have the name of my above variables: $obj->XYZ_hi['val'] = ...
CMarcera's user avatar
0 votes
1 answer
43 views

I want to store an property->object name in a table and access in code. What is the proper way to accomplish the following. $patient = new stdClass(); $patient->patient_number = '12345'; $cls = '...
Ken Roberts's user avatar
2 votes
2 answers
396 views

From what I can tell in the PHP Manual, it doesn't seem like there is much difference between defining a variable variable with double brackets or double dollar signs. $foo = 'hello'; $$foo = 'hi'; ...
Katrina's user avatar
  • 1,935
0 votes
4 answers
2k views

I'm trying to convert a PHP variable to a JS variable using a little helper function that uses variable variables. To simplify, here is what I'm trying to accomplish: $project_key = 'project 1'; ...
northamerican's user avatar