2017-01-18 6 views
-3

私はphpとhtmlを使用してホームラップダッシュボードを構築しています。現在、配列から情報を取り出し、div内に表示しようとしています。配列に提供される情報は、iframeのURLと、高さと幅の調整です。私の質問は、どのように私は正しく表示することができますこの配列の特定の要素を取得するだろうです。PHPを使用して多次元配列の特定の要素を取得する方法

$dl = [ 
    'dashlet1' => [ 
     'url' => 'some random url', 
     'height' => 'height=200', 
     'width' => 'width=450' 
    ], 
    'dashlet2' => [ 
     'url' => 'another random url', 
     'height' => 'height=200', 
     "width" => 'width=450' 
    ], 
    'dashlet3' => [ 
     'url' => 'another random url', 
     'height' => 'height=200', 
     'width' => 'width=450' 
    ], 
    'dashlet4' => [ 
     'url' => 'another random url', 
     'height' => 'height=200', 
     'width' => 'width=350' 
    ], 
    'dashlet5' => [ 
     'url' => 'another random url', 
     'height' => 'height=200', 
     'width' => 'width=450' 
    ], 
    'dashlet6' => [ 
     'url' => 'another random url', 
     'height' => 'height=200', 
     'width' => 'width=450' 
    ], 
    'dashlet7' => [ 
     'url' => 'another random url', 
     'height' => 'height=200', 
     'width' => 'width=350' 
    ], 
    'dashlet8' =>[ 
     'url' => 'another random url', 
     'height' => 'height=200', 
     'width' => 'width=450' 
    ] 

]; 
+0

http://php.net/manual/en/control-structures.foreach.phpマニュアルを読んで起動し – AbraCadaver

+0

と[MCVE] –

+0

'] [' url '] '。 [配列のドキュメントを参照](http://php.net/manual/en/language.types.array.php#language.types.array.syntax.accessing) –

答えて

0

あなたは、URLにアクセスしたいとします。あなたはまた、ループを使用することができるなど

echo $dl['dashlet1']['url']; 
echo $dl['dashlet2']['url']; 

を行うことによって

これを行うことができます。

foreach($dl as $key => $value) { 

     echo($key . " " . $value['url']); 
    } 
`$のDL [ 'dashlet6、例えば、特定の要素を取得するには
関連する問題