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 should 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:
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:or even better in my opinion: