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条)

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度