2017-03-06 1 views
1

Google 스프레드 시트 API를 사용하고 있으며 객체를 PHP의 배열로 변환하려고합니다.배열 객체로 객체를 변경할 수 없습니다

개체 또는 배열 키, 값 쌍과 같은 방법으로 액세스 할 수 있는지 알려주십시오. 누구든지 나를 도와 줄 수 있어요.

미리 감사드립니다.

Array 
(
[Google\Spreadsheet\Worksheetxml] => Array 
    (
     [id] => Array 
      (
       [0] => https://spreadsheets.google.com/feeds/worksheets/1l5g5HbOuaDVCXb1Z3mMk7UesdJ5OOsUtGEekqDXRd-s/private/full/od6 
      ) 

     [updated] => Array 
      (
       [0] => 2017-03-01T14:18:45.232Z 
      ) 

     [category] => Array 
      (
       [@attributes] => Array 
        (
         [scheme] => http://schemas.google.com/spreadsheets/2006 
         [term] => http://schemas.google.com/spreadsheets/2006#worksheet 
        ) 

      ) 

     [title] => Array 
      (
       [0] => Sheet1 
      ) 

     [content] => Array 
      (
       [0] => Sheet1 
      ) 

     [link] => Array 
      (
       [0] => SimpleXMLElement Object 
        (
         [@attributes] => Array 
          (
           [rel] => http://schemas.google.com/spreadsheets/2006#listfeed 
           [type] => application/atom+xml 
           [href] => https://spreadsheets.google.com/feeds/list/1l5g5HbOuaDVCXb1Z3mMk7UesdJ5OOsUtGEekqDXRd-s/od6/private/full 
          ) 

        ) 

       [1] => SimpleXMLElement Object 
        (
         [@attributes] => Array 
          (
           [rel] => http://schemas.google.com/spreadsheets/2006#cellsfeed 
           [type] => application/atom+xml 
           [href] => https://spreadsheets.google.com/feeds/cells/1l5g5HbOuaDVCXb1Z3mMk7UesdJ5OOsUtGEekqDXRd-s/od6/private/full 
          ) 

        ) 

       [2] => SimpleXMLElement Object 
        (
         [@attributes] => Array 
          (
           [rel] => http://schemas.google.com/visualization/2008#visualizationApi 
           [type] => application/atom+xml 
           [href] => https://docs.google.com/spreadsheets/d/1l5g5HbOuaDVCXb1Z3mMk7UesdJ5OOsUtGEekqDXRd-s/gviz/tq?gid=0 
          ) 

        ) 

       [3] => SimpleXMLElement Object 
        (
         [@attributes] => Array 
          (
           [rel] => http://schemas.google.com/spreadsheets/2006#exportcsv 
           [type] => text/csv 
           [href] => https://docs.google.com/spreadsheets/d/1l5g5HbOuaDVCXb1Z3mMk7UesdJ5OOsUtGEekqDXRd-s/export?gid=0&format=csv 
          ) 

        ) 

       [4] => SimpleXMLElement Object 
        (
         [@attributes] => Array 
          (
           [rel] => self 
           [type] => application/atom+xml 
           [href] => https://spreadsheets.google.com/feeds/worksheets/1l5g5HbOuaDVCXb1Z3mMk7UesdJ5OOsUtGEekqDXRd-s/private/full/od6 
          ) 

        ) 

       [5] => SimpleXMLElement Object 
        (
         [@attributes] => Array 
          (
           [rel] => edit 
           [type] => application/atom+xml 
           [href] => https://spreadsheets.google.com/feeds/worksheets/1l5g5HbOuaDVCXb1Z3mMk7UesdJ5OOsUtGEekqDXRd-s/private/full/od6/-u3c64m 
          ) 

        ) 

      ) 

    ) 

[Google\Spreadsheet\WorksheetpostUrl] => Array 
    (
     [0] => Array 
      (
       [0] => https://spreadsheets.google.com/feeds/worksheets/1l5g5HbOuaDVCXb1Z3mMk7UesdJ5OOsUtGEekqDXRd-s/private/full 
      ) 

    ) 

) 
+0

무엇을 시도 했습니까? – hassan

답변

1

이와 같이 사용해야합니다.

foreach($yourArray as $key=>$value){ 
    $Updatedate = $value['updated'][0]; 
    $UpdateId = $value['id'][0]; 
} 
+0

수락 해 주셔서 감사합니다. – vel

0

당신과 같이 캐스트 배열을 사용하여 배열로 객체 변환을 시도 할 수 :

$array = (array) $obj; 
+0

작동하지 않습니다 – user6016913

+0

변환하려는 개체를 게시 할 수 있습니까? – Freid001

+0

위의 배열 ^을 게시했습니다. id 요소에 접근하기를 원하면 다음과 같이 할 수 있습니다 : $ id = $ array [ 'Google \ Spreadsheet \ Worksheetxml'] [ 'id'] [0]; – Freid001

관련 문제