js变量名中的数字用另一个变量替换怎么实现
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了js变量名中的数字用另一个变量替换怎么实现相关的知识,希望对你有一定的参考价值。
[javascript]var test=\' colkey: "col", colsinfo: "NameList" \'
var test=\' colkey: "col", colsinfo: "NameList" \'
2.把文本转化为对象
[javascript]
var test=\' colkey: "col", colsinfo: "NameList" \'
var obj2=eval("("+test+")");
alert(obj2.colsinfo);
var test=\' colkey: "col", colsinfo: "NameList" \'
var obj2=eval("("+test+")");
alert(obj2.colsinfo);
3.把文本转化为数组
[javascript]
var test=\'["colkey", "col", "colsinfo","NameList" ]\'
var obj2=eval("("+test+")");
alert(obj2.length); 参考技术A var x="var a1";
var b="zz";
x.replace(/[0-9]1/,b);
eval(x); 参考技术B var a="a123",b="b";
a.replace(/[0-9]1/,b)
PHP变量名中的变量
Create variable named PHP variables. Having dynamically named variables can be helpful when dealing with loops and arrays. For example instead of having seven if () statements for handling seven individual days of the week, you could reduce it to one if statement by doing a loop with seven iterations and dynamically create your variable names.
// create fifty (50) variable named variables named my_var1, my_var2... $name = "my_var"; for ($i = 0; $i < 50; $i++) { } echo $my_var3; // slightly more complex example to create a variably named array w/concatenation $name = "my_var"; for ($i = 1; $i <=5; ++$i) echo $my_var2_arr;
以上是关于js变量名中的数字用另一个变量替换怎么实现的主要内容,如果未能解决你的问题,请参考以下文章
LibreOffice Calc:用另一个数字替换数字,但只能在函数内部?
sed在替换的时候,使用变量中的值?如何在sed实现变量的替换?获取到变量中的值?
bash shell参数展开(Shell Parameter Expansion):替换变量(variable)中的字符串