<?php

if (isset($_POST['pid'])) {
  
  if (isset($response['items']) && is_array($response['items'])) {
      $user_list = array_map(function($user) {
          return [
              'pid' => $user['pid'] ?? '-',
              'firstname' => $user['firstname'] ?? '-',
              'lastname' => $user['lastname'] ?? '-',
              'email' => $user['email'] ?? '-',
              'Department' => $user['custom_field_1'] ?? '-', // Example, adjust as needed
              'Designation' => $user['custom_field_2'] ?? '-', // Example, adjust as needed
              'work_phone' => $user['work_phone'] ?? '-',
              'Company' => $user['company'] ?? '-'
          ];
      }, $response['items']);
        
      // Filter the user list to get the user with pid='sugeorg'
      $user_details_fetch = array_filter($user_list, function($user) {
        $_SESSION["PID_TEST"]=$_POST['pid'];
          return $user['pid'] === $_POST['pid'];
      });
  
   
      
  }
  }

  ?>