可能重复:
如何从特定 PHP 数组中提取数据
我有一个数组,我试图从特定键中获取所有元素。键是shard3
. 结果应该是'user'=>'root','password'=>'3', 'db'=>'test', 'port'=>3307
private $shard_list = array (
'shard1' => array( 'host'=>'127.0.0.1',
'user'=>'root',
'password'=>'1',
'db'=>'test',
'port'=>3306
),
'shard2' => array( 'host'=>'127.0.0.2',
'user'=>'root',
'password'=>'2',
'db'=>'test',
'port'=>3307
),
'shard3' => array( 'host'=>'127.0.0.3',
'user'=>'root',
'password'=>'3',
'db'=>'test',
'port'=>3307
),
'shard4' => array( 'host'=>'127.0.0.4',
'user'=>'root',
'password'=>'4',
'db'=>'test',
'port'=>3307
)
我想阅读shard3
. 读取所有元素的方法是什么?