I want to create an array that looks like this
$appsByOs = Array(
osName1 =>Array(0=>app1,1=>app2)
osName2 =>Array(0=>app1,1=>app2)
etc.....
)
how could i do this inside of a foreach loop?
foreach($osInstanceNames as $osInstanceName){
$appNames(array of app names for current os)
}
thanks
All you should need to do is this.
$appsByOs = Array();
foreach($osInstanceNames as $osInstanceName){
$appsByOs[$osInstanceName] = $appNames;
}
Recovering the last post and adding the possibility to have more than one app for an os instance
$appsByOs = Array();
foreach($osInstanceNames as $osInstanceName){
$appsByOs[$osInstanceName][] = $appNames;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.