0

最後の配列データ、つまりSiteName、Url、Titleをphpの変数に抽出する必要があります。



array
  'ApplicableProductOfferings' => 
    array
      0 => string 'EasyDemo' (length=10)
  'Artist' => string 'Hello' (length=10)
  'ReferralDestinations' => 
    array
      0 => 
        array
          'SiteName' => string 'gettyimages' (length=11)
          'Url' => string 'http://www.gettyimages.com/detail/160414706' (length=43)
          'Title' => string 'Pixie Lott Launches The New BlackBerry Z10' (length=42)
          'UrlComp' => string 'http://localhost.com' (length=197)
          'UrlPreview' => string 'http://localhost.com' (length=164)
          'UrlThumb' => string 'http://localhost.com' (length=82)
          'UrlWatermarkComp' => string 'http://localhost.com' (length=197)
          'UrlWatermarkPreview' => string 'http://localhost.com
4

3 に答える 3

0

これは、データを配列に格納する方法によって異なります。最後の配列データがすでにある配列がある場合、それは非常に簡単です。

foreach ($myArray as $var) {
  echo $var;
}

または、$ myArray ['SiteName']、$myArray['Url']などのように個々の要素にアクセスします。

$arrayOfArraysと呼ばれる配列の配列に上記のデータがあると仮定します

foreach ($arrayOfArrays as $myArray) {

  // $myArray now holds first array, second array etc as the loop is executed
  // First time it holds 'ApplicableProductOfferings', second time 'ReferralDesinations'..

  // If the array is 'ReferralDesitnations' you can loop through that array
  // to get the elements you are looking for SiteName etc as below

  foreach ($myArray as $URLElement) {
    echo $URLElement;
  }
}
于 2013-02-07T07:27:24.893 に答える
0

これを試して.......

   foreach($data as $dat)
   {
       foreach($dat['ReferralDestinations'] as $key => $d) 
        {
           echo $d['SiteName'];
           echo $d['Url'];
           echo $d['Title'];
        }
    }
于 2013-02-07T07:08:29.820 に答える