Okay... I've run into a bit of a snag here. 🙂

What I have is an array inside of an array in a language file.

'status' => array(
			'here' => 'Here',
			'busy' => 'Busy',
			'away' => 'Away',
			'brb'  => 'BRB',
		),

What I would like to be able to do is to call custom variables from a mysql table that'll also show up in this particular status array. I'm just not sure if I can do this... or even if it's possible to do. Any type of help, or links to references would be awesome and appreciated. Thanks. 🙂

    you want to query the database for the values in this array? do you want the array keys or values...or both? anyway:

    $status = array(
    	'here' => 'Here',
    	'busy' => 'Busy',
    	'away' => 'Away',
    	'brb'  => 'BRB'
    );
    
    // for the array values
    $sql = 'SELECT * FROM table WHERE field IN(' . implode(',', $status) . ')';
    
    // for the array keys
    $sql = 'SELECT * FROM table WHERE field IN(' . implode(',', array_keys($status)) . ')';
    

      I don't... know? lol. Arrays have always confused the heck out of me.

      I have this query...

      $sql = 'SELECT nickname, nicknameid FROM table_nicknames WHERE userid = id';

      What I want to know is if it's possible to append the data I get from this query and put it into the existing array.

      So it'd be something like this...

      $status = array(
          'here' => 'Here',
          'busy' => 'Busy',
          'away' => 'Away',
          'brb'  => 'BRB',
          'nicknameid1' => 'nickname1',
          'nicknameid2' => 'nickname2',
      ); 

      I'm just not even sure if such a thing is possible.

        yes [man]array_merge[/man], is the easiest way however you can do it the manual way of e.g

        //array with data $existingArray
        foreach ($array as $key => $value)
            $existingArray[$key] = $value;
        

        However thats basically how [man]array_merge[/man] works

          So, I need to create a second array with the data I want added, and then merge them together? All of this is just so confusing to me, lol.

            Write a Reply...