开发者

Have problem changing a value in an array

I have a multi-dimensional array with 4 entries in each value - (1st name, last name, email, password). I am trying to format the password value so I can insert it into a database. As you can see, my results are not what I need. Why is this the result and what s开发者_运维知识库hould I do to get my intended result? Thanks

php > $newlines[1][3] = "PASSWORD($newlines[1][3)]";  
php > echo $newlines[1][3];  
PASSWORD(Array[3)]


You have a typo:

php > $newlines[1][3] = "PASSWORD($newlines[1][3)]";
                                                ^

But this not the only problem. You are accessing a multi-dimensional array and therefore, you have to put the array access into brackets {}. Otherwise, PHP would only subsitute the variable up to the first index (i.e. $newlines[1]). See also variable parsing.

And as $newlines[1][3] is most likely a string, you should also put quotation marks around it:

php > $newlines[1][3] = "PASSWORD('{$newlines[1][3]}')";

or even better in my opinion:

php > $newlines[1][3] = "PASSWORD('" . $newlines[1][3] . "')";


"PASSWORD($newlines[1][3)]"

Should be

"PASSWORD({$newlines[1][3]})"


This appears to be a quotation mark placement problem. You want the result of the function Password() rather than the string "Password(-arguments-)".

Drop the quotations around the right side:

php > $newlines[1][3] = password($newlines[1][3]);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜