I'm a beginner to PHP and am currently working on re-coding a small site from Classic ASP (VB) to PHP, and I was wondering if there was a fairly direct 'translation' in taking this concept from one to the other language?
I know that nested foreach loops would do the job, yet, I am curious if a for outer loop, with a foreach inner loop would work?
Here's what I've attempted to do. For some reason, the variable $strMonth_Alpha does not return. Thanks for any leads.
PHP Code:
$strMonthList='01,January;02,February;03,March;04,April;05,May;06,June;07,July;08,August;09,September;10,October;11,November;12,December';
$arrMonthList=explode(';',$strMonthList); //create the outer array
//print_r(array_values($arrMonthList));
for ($ii=0; $ii<count($arrMonthList); $ii++) {
$M=explode(',',$arrMonthList[$ii]); //create the inner array
//print_r(array_values($M));
$myArrayCount=0;
foreach($M as $a => $item) {
if ($myArrayCount==0) {
$strMonth_Num=$M[$myArrayCount];
//echo '<BR>$strMonth_Num...'.$strMonth_Num.'<BR>';
}
if ($myArrayCount==1) {
$strMonth_Alpha=$M[$myArrayCount];
}else{
$strMonth_Alpha='';
$myArrayCount=($myArrayCount+1);
}
}
}//to next month