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

报告相同问题?