January 26th, 2013, 02:29 AM
Passing variable into an array
I'm very new to php development. I'm trying to pass a variable into an array, looks like php does not like it. Is there any work around to pass a dynamic variable into a php array? I have a result set which is a multi-dimensional array, the variable I'm trying to pass into the second array is part of the result set.
a and b are column aliases. I need $name to be part of each row
Thanks for any suggestions!
January 26th, 2013, 08:45 AM
I don't understand what you mean. Syntactically, the example you gave is missing a $ in front of array1 in the first line (assuming array1 is a variable name) and is missing a semicolon at the end of the line in the second line.
Also the second line doesn't actually do anything, even those it is valid.
January 26th, 2013, 09:21 AM
Don't put quotes around variables if they're by themselves. It causes PHP to try to use them as strings.
HEY! YOU! Read the New User Guide and Forum Rules
"They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin
"The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002
Think we're being rude? Maybe you asked a bad question
or you're a Help Vampire.
Trying to argue intelligently? Please read this.