1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Rep Power

    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!
  2. #2
  3. No Profile Picture
    Lost in code
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2004
    Rep Power
    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.

    Originally Posted by Spad
    Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around
  4. #3
  5. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Pennsylvania, USA
    Rep Power
    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.

IMN logo majestic logo threadwatch logo seochat tools logo