181 questions
3 votes
1 answer
147 views
How to convert a string in an array to variable using the array index in PHP [duplicate]
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 ...
0 votes
2 answers
96 views
In PHP, how to recurse through a Closure when the variable name holding the anonymous function is a variable-variable
I have a list of about 100 articles, and within each article is a list of clauses. The clauses are a list of varying levels deep. $clauses = array( [ 'Fields' => ['Clause' => 'clause 1', '...
1 vote
2 answers
193 views
Variable variable is not accessible within callback scope while using arrow function syntax (Warning: Undefined variable)
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. ...
1 vote
2 answers
4k views
Streamlit dynamic UI to generate dynamic input widgets depending on value from a different input widget
I want to open this post as I can't find anything on the official documentation from streamlit or any resources that mentioned how to do this. After some trial and error I have figured out a way, and ...
0 votes
0 answers
64 views
How can I echo a php variable that's INSIDE a php string variable?
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 ...
0 votes
2 answers
113 views
How to generate properties of instances of classes in batches?
I have a class named MyClass. I want to generate the attributes k_10sec to k_1d of the instance in batches when generating instances of the class. How do I modify the code? bars = ['10sec', '1min', '...
0 votes
2 answers
321 views
PHP variable variable not overriding original variable
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 ...
0 votes
1 answer
1k views
How do I create a dynamic variable based on the row number I am iterating over in an Excel sheet while using openpyxl?
I am trying to iterate over all the rows in an Excel worksheet and set a variable based on the cell that is currently being iterated over. Below is the code that I am using: import openpyxl from ...
0 votes
3 answers
3k views
How to check if function exists inside another function using Javascript
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 = ...
1 vote
3 answers
391 views
Variable variables as parameters of custom function in usort()
I've been playing around and seeing if I can set up a more dynamic method in PHP. usort( $dataset, function($a, $b){ return strcasecmp($a[$this->parameters], $b[$this->parameters]...
2 votes
1 answer
707 views
Trying to access $_SERVER(or any global) variable from string name [duplicate]
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 ...
2 votes
1 answer
116 views
Variable Variables with array element values syntax
I want to create a session variable but the session variable name I want to be dynamic. So what I need is the proper syntax for a variable name that is a $_SESSION variable. I have tried the code ...
1 vote
1 answer
92 views
How can I access a specific depth of an associative array with variable variables
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 ...
0 votes
1 answer
241 views
Variable Variable in django template [closed]
view.py variable = 'amount' amount = 200 print(variable) #actual: 'amount' expected: 200 In such case, is it possible to use Variable Variable like PHP? in php, I could do $variable = 'amount'; $...
0 votes
1 answer
44 views
How would I use the contents of one variable to create the name of another? [duplicate]
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 ...