我想创建一个看起来像这样的数组
$appsByOs = Array(
osName1 =>Array(0=>app1,1=>app2)
osName2 =>Array(0=>app1,1=>app2)
etc.....
)
我怎么能在foreach循环中做到这一点?
foreach($osInstanceNames as $osInstanceName){
$appNames(array of app names for current os)
}
感谢
答案 0 :(得分:0)
你需要做的就是这个。
$appsByOs = Array();
foreach($osInstanceNames as $osInstanceName){
$appsByOs[$osInstanceName] = $appNames;
}
答案 1 :(得分:0)
恢复上一篇文章并添加为os实例提供多个应用程序的可能性
$appsByOs = Array();
foreach($osInstanceNames as $osInstanceName){
$appsByOs[$osInstanceName][] = $appNames;
}