这里是github要点链接: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',
)
您可能需要执行以下操作:
$featureList = array();
foreach(Petition::getFeaturedPetitions() as $petition)
{
$featureList[$petition->id] = 'before '.$petition->call_to_action.'petition';
}