[英]PHP string array variable: how to assign values
I guys, pretty new to php and I couldn't find this answer in the manual. 伙计们,对于php来说还很陌生,我在手册中找不到这个答案。 Basically if I have this situation: 基本上,如果我有这种情况:
$errors = array();
and I want to assign more than string to $error, depending on which input filed I'm testing, how do I do? 并且我想为$ error分配多个字符串,具体取决于我正在测试的输入文件,我该怎么办? I know I can do this for the first one: 我知道我可以在第一个中做到这一点:
$errors[] = 'You must select a title';
and that saves the string in $errors[0] But if afterwards I do: 并且将字符串保存在$ errors [0]中,但是如果之后我这样做:
$errors[] = 'Insert a first name';
what happens to the second string, is it saved in $error[1]? 第二个字符串会发生什么,是否保存在$ error [1]中? thanks 谢谢
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.