【问题标题】:Laravel making array from collection in controller fileLaravel 从控制器文件中的集合制作数组
【发布时间】:2014-09-04 20:36:51
【问题描述】:

这里是 github gist 链接:https://gist.github.com/gupta2205/b33dcf762876e5df34d9

//trying to make array out of fetured petitions 
// i guess i am doing something wrong in writing it 
//do i need "foreach" here ? to get individual petition->call_to_action access and set key value in array or how can i do it ? please suggest

   $featureList = array(
    '0' => 'before '.Petition::getFeaturedPetitions()->call_to_action.'petition',
    '1'=>  'before '.Petition::getFeaturedPetitions()->call_to_action.'petition',
            )  

【问题讨论】:

    标签: php arrays laravel drop-down-menu


    【解决方案1】:

    你可能不得不这样做:

    $featureList = array();
    
    foreach(Petition::getFeaturedPetitions() as $petition)
    {
        $featureList[$petition->id] = 'before '.$petition->call_to_action.'petition';
    }
    

    【讨论】:

      猜你喜欢
      • 2020-11-13
      • 2017-08-25
      • 1970-01-01
      • 1970-01-01
      • 2021-04-17
      • 2016-07-14
      • 2021-11-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多