[Solved] How retrieve specific duplicate array values with PHP


If you need do search thru yours array by $id:

foreach($array as $value)
{
   $user_id = $value["id"];
   $userName = $value["name"];
   $some_key++;

   $users_array[$user_id] = array("name" => $userName, "upline" => '1');
}

function get_downline($user_id, $users_array){
     foreach($users_array as $key => $value)
     {
         if($key == $user_id)
         {
              echo $value["name"];
              ...do something else.....
         }
     }
}

or to search by ‘upline’:

function get_downline($search_upline, $users_array){
         foreach($users_array as $key => $value)
         {
             $user_upline = $value["upline"];
             if($user_upline == $search_upline)
             {
                  echo $value["name"];
                  ...do something else.....
             }
         }
    }

solved How retrieve specific duplicate array values with PHP