2016-07-29 10 views
1

私がエコーした配列のリスト複数の配列からデータを取得

Array ( [CustomerID] => manish14 [TicketID] => 45691 [TicketNumber] => 1045828 [CustomerUserID] => ) Array ( [CustomerID] => [email protected] [TicketID] => 45686 [TicketNumber] => 1045823 [CustomerUserID] => [email protected] ) Array ( [CustomerID] => [email protected] [TicketID] => 45661 [TicketNumber] => 1045798 [CustomerUserID] => [email protected] ) ........ ........ ........

各配列のcustomerID、TicketID、TicketNumberを表形式で表示したいとします。どのようにそれらの値を取得することができます。私は複数のforeachループthatsなぜ私はこれらの値を取得する問題を抱えているこれがあります。 誰もが見たいと思っている私のコードです。 phpfiddle.org/main/code/wb4u-nrsj

私のコードはthis PhpFiddleです。

+0

説明を正しく行うことができますか? –

答えて

1
<?PHP 
error_reporting(0); 
//////// OTRS specific information //////// 
$url = "https://otrs.classic.com.np/otrs/rpc.pl"; //// URL for OTRS server 
$username = "ctdeveloper"; //// SOAP username set in sysconfig 
$password = "ctdeveloper"; //// SOAP password set in sysconfig 
$TicketID = $_GET['id']; 
######################################################################## 
#### You don't have to change anything below here, although you can #### 
######################################################################## 
#### Initialize new client session #### 
echo "<table><tr><th>CustomerID</th><th>TicketID</th><th>TicketNumber</th></tr>"; 
$client = new SoapClient(
    null, 
    array(
     'location' => $url, 
     'uri' => "Core", 
     'trace' => 1, 
     'login' => $username, 
     'password' => $password, 
     'style' => SOAP_RPC, 
     'use' => SOAP_ENCODED 
    ) 
); 

#### Initialize new client session #### 
$client = new SoapClient(
    null, 
    array(
     'location' => $url, 
     'uri' => "Core", 
     'trace' => 1, 
     'login' => $username, 
     'password' => $password, 
     'style' => SOAP_RPC, 
     'use' => SOAP_ENCODED 
    ) 
); 

$queues = array(1 => "Postmaster", 
    2 => "Raw", 
    3 => "Junk", 
    4 => "Retail Support", 
    5 => "Enterprise Support", 
    6 => "Sales", 
    7 => "Marketing", 
    8 => "Fiber Survey", 
    9 => "Fiber Support", 
    10 => "Billing", 
    11 => "NOC", 
    12 => "Wireless Support", 
    13 => "Core-Tasks", 
    14 => "Chitwan", 
    15 => "Developer", 
    16 => "Operations", 
    17 => "Administration", 
    18 => "Hetauda", 
    19 => "Business", 
    20 => "Info", 
    21 => "Corporate", 
    22 => "Wireless Survey", 
    23 => "Recovery", 
    24 => "L2-Support", 
); 

foreach ($queues as $queue_number => $queue_name) { 
#### Create and send the SOAP Function Call #### 
    $TicketDetail_search = $client->__soapCall("Dispatch", 
     array($username, $password, 
      "TicketObject", "TicketSearch", 
      "Result", "ARRAY", 
      "UserID", 1, 
      "QueueIDs", array($queue_number), 
      "StateType", "open" 
     )); 

    // REMOVE s-gensym 
    $ticketInfo = array(); 
    if ($TicketDetail_search) { 
     foreach ($TicketDetail_search as $name => $value){ 
      if (false !== strpos($name, "s-gensym")) 
      { 
        $ticketInfo[] = $value; 
      } 
     } 
    } 

    foreach($ticketInfo as $TicketID) 
    { 
     $TicketDetail_get = $client->__soapCall("Dispatch", 
      array($username, $password, 
       "TicketObject", "TicketGet", 
       "TicketID", $TicketID, 
      )); 
     foreach($TicketDetail_get as $t) 
     { 
      $ticketInfo1 = array(); 
      $i = 0; 
      foreach ($TicketDetail_get as $name => $value){ // explode the xml response 
       if (false !== strpos($name, "s-gensym")){ 
        $temp[$i] = $value; 
        if($i > 0) { 
         $v = $temp[$i-1]; 
         if($i % 2 != 0){ 
          $ticketInfo1[$v] = $value; 
         } 
        } 
        $i++; 
       } 

      } 

     } 
     echo "<tr>"; 
     echo "<td>" . $ticketInfo1['CustomerID'] . "</td>"; 
     echo "<td>" . $ticketInfo1['TicketID'] . "</td>"; 
     echo "<td>" . $ticketInfo1['TicketNumber'] . "</td>"; 

     echo "</tr>"; 





    } 


    } 
echo "</table>"; 
?> 

これはあなたが探しているものですか?

+0

これは役に立ちませんでした。ここに私のコードです。 phpfiddle.org/main/code/wb4u-nrsj –

+0

これはここでも出力されますか? –

+0

私はOTRSプロジェクトに取り組んでいます。私はデータを呼び出すために石鹸APIを使用しています。私は上記の配列のリストからcustomerID、TicketID、およびTicketNumberを取得したいだけです。 –

関連する問題