How to assign one array to another in php, when you have to build the name of the array to be assigned from a string and a variable?
Get the solution ↓↓↓Solution:
Remove the $ sign in your string and just assign the name as a string and use variable variable.
$select_options = $option_name . '_options';
print_r($$select_options);
Answer
Solution:
$varname = $option_name.'_options';
$select_options = $$varname;
Answer
Solution:
foreach($options as $option_name => $option_value) {
...
$select_options[] = $option_name; //if you want an array of keys from $options
...
}
Or better solution:
$select_options = array_keys($options);
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: composer detected issues in your platform: your composer dependencies require a php version ">= 7.3.0".
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.