Jump to content

illegal offset question


ballhogjoni

Recommended Posts

I have an illegal offset warning do to this  foreach loop:

 

foreach($aAvailableMonthsDates as $key=>$sStartDate){
$aAvailableMonths[$sStartDate] = date("F - Y", strtotime($sStartDate));
}

 

if I add single quotes around the index in the $aAvailableMonths array the warning goes away. My question is if I do that will it affect the actual value if the $sStartDate. What I mean is will the index now be a string that equals $sStartDate or will it actually be the value of the $sStartDate variable?

 

IE, can I do this with out any problems occuring:

foreach($aAvailableMonthsDates as $key=>$sStartDate){
$aAvailableMonths['$sStartDate'] = date("F - Y", strtotime($sStartDate));
}

Link to comment
https://forums.phpfreaks.com/topic/122440-illegal-offset-question/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.