dqknycyt92288 2014-01-08 22:07
浏览 20

获取阵列数据

The following is a profile array printed using r_print:

Array
(
    [0] => Array
        (
            [Title] => Profile
            [Name] => Veritas
            [NKey] => Key_1
            [SKey] => Key_2
        )

    [1] => Array
        (
            [Title] => Access
            [Admin] => True
            [Banned] => False
            [Public] => True
        )

)

What I'm trying to do, is simply retrieve elements of that array.

IE,

$profile[] = ...; //GET_ARRAY
$user = $profile[0]['Name'];
$key_1 = $profile[0]['NKey'];
$key_2 = $profile[0]['SKey'];
$admin = $profile[1]['Admin'];

For some reason, the above code doesn't work, though logically it should work without a problem. What IS returned, is just the character 'A' if I target anything within the array.

  • 写回答

2条回答 默认 最新

  • dongshen7407 2014-01-08 22:09
    关注

    You are adding another level to your array by assigning the array to $profile[]. The brackets turn $profile into an array and then adds that array to it causing the extra level.

    $profile[] = ...; //GET_ARRAY
    

    should just be

    $profile = ...; //GET_ARRAY
    
    评论

报告相同问题?

悬赏问题

  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图