1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

PHP Help pls - Arrays

Discussion in 'XenForo Development Discussions' started by Marc, May 22, 2011.

  1. Marc

    Marc Well-Known Member

    Hi Peeps,
    I am a very new coder in PHP and attempting a decent addon for xenforo. Reason I am doing so is I will learn a lot about both PHP and the framework as I go alone (at least thats the theory LOL). However I am struggling with something I need to do with some arrays.

    Here is the scenario. I have an array with values like so:

    I need to get the avatars for the users, so was going to use
    So .... Here is my dilema. I cant figure firstly how to pass only a list of the users into the array from what I have above, and secondly how to then merge that into the original array as 'avatarURL'=>'blah'

    Really hope that makes sense. I could start looping through things etc etc, but Im sure there must be a better way of doing this.

    Any help would be greatly appreciated.
  2. ragtek

    ragtek Guest

    You can't pass an array with users to a method, which requires only 1 user;)
    You'll want to use foreach for this.

    $users = array(....);

    foreach (
    $users AS &$user{
    $user[$user['user_id]['avatar_url'] = XenForo_Template_Helper_Core::getAvatarUrl($user,'m')
    Dan likes this.
  3. Marc

    Marc Well-Known Member

    So dont understand why it takes array as the input in that function... Tried to pass in just the userid but was given that message that says "Your an idiot" ... Least that was how I read the error message LOL.
  4. Marc

    Marc Well-Known Member

    LMFAO and now I get

    Undefined index: gender

    My brain hurts LMFAO .....
  5. Marc

    Marc Well-Known Member

    This is the code I have in my Model at the moment:

    class dcXenMapMe_Model_MapMe extends XenForo_Model

    public function 
    $limit 5000;
    $userModel XenForo_Model::create('XenForo_Model_User');
    $data $this->_getDb()->fetchAll($this->limitQueryResults("
                SELECT member_id, 
                FROM dc_MapMe_Markers

            foreach (
    $data as $key => $values)
    $i $key 1;
    $retval[$i] = array(
    'user'     => $values['member_id'],
    'lat' => $values['lat'],
    'lon' => $values['lon']
    foreach (
    $retval AS &$user)
    $user['user']['avatar_url'] = XenForo_Template_Helper_Core::getAvatarUrl($user);


Share This Page