我爱占星网 我爱占星网
首页
编程
java
php
前端
首页 编程 java php 前端

获取数组元素

This problem is old and basic but I can't figure out a better way to get it right without looping through the whole array

$a=array(
'a'=>array
    (
      'x'=>'something',
      'y'=>'somethingelse',
      'z'=>'another thing'
    );
);

I would like to get the value of 'y' key.

I try this

foreach($a as $k=>$v)
{
  foreach($v as $vv)
  {
    return $v['y']
  }
}

UPDATE
Thanks for your posts. How stupid I am :shy:

echo $a['a']['y'];

This is me adding characters to reach the 30 char minimum.

近期文章

  • PHP preg_replace URI在phpBB中
  • Cakephp和设置故障通知
  • 调整文本中<img>标签的宽度/高度
  • 数据库查询显示在视图中而不是$ data
  • 使用php将列表转换为数组。 怎么样?
  • 如何以当前登录用户的身份发送推文?
  • PHP防止HTML列表的错误数据收集(选择,复选框,广播)
  • 基于会话的登录无法正常工作
  • cakephp间接修改重载属性PaginatorHelper
  • codeigniter的url编码是否必要?
  • 表格不会发送信息到电子邮件地址(虽然工作在其他地方)
  • 使用php编辑mysql记录数据库
  • 如何将CodeIgniter的/ TankAuth的注册表和登录表单放在同一页面上?
  • 带有FastCGI的PHP open_basedir
  • 从数据库运行脚本
  • 如何多表?
  • mod_rewrite $ 1给了我错误的值
  • php gettext没有正确显示法语口音
  • 将OpenERP与CodeIgniter XML RPC库连接
  • 在PHP常量和安全性中存储数据库凭据[重复]

Copyright ©2022 我爱占星 All Rights Reserved.

浙ICP备2022030071号-1

部分图文来自网络,如有侵犯您的版权,请告诉我们删除

友情链接:代码精华