Quantcast
Channel: 配列タグが付けられた新着記事 - Qiita
Viewing all articles
Browse latest Browse all 834

多次元配列について

$
0
0

配列の中のキーを配列として格納することが可能。

meet.php
$meet=array('鶏肉'=>array('price'=>68,'stock'=>10),'豚肉'=>array('price'=>89,'stock'=>15),'牛肉'=>array('price'=>128,'stock'=>8));foreach($meetas$name=>$value){echo$name.'は、100グラム'.$value['price'].'円、在庫は'.$value['stock'].'個です。'.'<br>';}

↓実行結果

meet.php
鶏肉は、100グラム68円在庫は10個です豚肉は、100グラム89円在庫は15個です牛肉は、100グラム128円在庫は8個です

複雑な構造を持つデータの配列として定義することが出来ます。


Viewing all articles
Browse latest Browse all 834

Trending Articles