在ASC为了赋值给一个变量更改变量名(编号)或添加号码 [英] Changing variable name (numbering) or adding numbers to a variable in asc order to assign values

查看:148
本文介绍了在ASC为了赋值给一个变量更改变量名(编号)或添加号码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何改变变量名按升序值分配给它们编号。
例如:car_1,car_2,car_3,car_4 ........等等..
我的编码是一样的东西;

How to change the variable name numbering in ascending order to assign values to them. eg: car_1, car_2, car_3, car_4........ so on.. my coding is something like;

for (i=1; i<20;i++){
$var[i] = $_POST["car_"i];
}

foreach ......so on........

echo $var[12]."<br/>";

我需要一种方式来增加car_的数目,以每辆车值分配给'$ VAR阵列。我尝试添加这样的:

I need a way to increase the number of 'car_' to assign each car value to the '$var' array. I have tried to add it like this:

$var[i] = $_POST["car_"&i];

$var[i] = $_POST["car_"i""];

和没有这些工作。我非常AP preciate您的帮助来解决这个问题。

and none of these work. I would very much appreciate your help to solve this.

推荐答案

如果你的意思是要追加的字符串,然后做到这一点:

If you mean to append strings then do this:

for ($i=1; $i<20;$i++) {
   $var[$i] = $_POST["car_".$i];
}

这篇关于在ASC为了赋值给一个变量更改变量名(编号)或添加号码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆