duanfan8699 2014-07-07 12:57
浏览 42
已采纳

如何在php中调用数组索引[关闭]

I have button with different id's in which i have put them into array so that i can used to anywhere in my project.Just i am not finding way to call them in my project. So i want to use this button separately depending on my requirement. Here is my code:

$page['button'] = array(
    1 => array( 'Save','pfeil2r','',"'#'",'','','saveId'),
    2 => array( 'Cancel','pfeil2r','',"'#'",'','','CancelId'),
    3 => array( 'Remove Widget','pfeil2r','',"'#'",'','','removewidgetId'), 

And i want to know how can i call them in this:

'.CreateButton($page['button']).'
  • 写回答

2条回答 默认 最新

  • dou2347 2014-07-07 13:04
    关注

    I think you don't realy get the way PHP is handling objects and arrays. As kingkero said, the proper way to access your buttons by "id" is

    $page['button']['Your id']
    

    As so, you will have to change function that you use to create the actual button. You could create an object that is callable the way you want, but it will be pretty hacky and unlogic. Keep things simple, just pass the proper array entry to the creation method.

    KISS.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 BP神经网络控制倒立摆
  • ¥20 要这个数学建模编程的代码 并且能完整允许出来结果 完整的过程和数据的结果
  • ¥15 html5+css和javascript有人可以帮吗?图片要怎么插入代码里面啊
  • ¥30 Unity接入微信SDK 无法开启摄像头
  • ¥20 有偿 写代码 要用特定的软件anaconda 里的jvpyter 用python3写
  • ¥20 cad图纸,chx-3六轴码垛机器人
  • ¥15 移动摄像头专网需要解vlan
  • ¥20 access多表提取相同字段数据并合并
  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算