newbornultra Posted November 22, 2012 Share Posted November 22, 2012 Hello, I have created an array for every day of a month. Eg, Element 0 is Day 1 etc, so there can be in theory 28 -31 elements depending on the month. The values of each element are set to 0. I am looking to add increment the value of a day if the present element is 15 minutes or more before the previous access. I have had a go at this and I get this error: Notice: A non well formed numeric value encountered for ($i=0;$i<sizeOf($newList);$i++) { //echo $newList[$i]->ip." "; if (($newList[$i]->ip)==$prevIp) { if ($i>0) { $minutes_to_add = 15; $time = new DateTime($newList[$i-1]->time); $time2=$time; $time2->add(new DateInterval('PT' . $minutes_to_add . 'M')); $stamp = $time2->format('Y-m-d H:i:s'); $iTime=new DateTime($newList[$i]->time); $interval=date_diff($time,$iTime); if ($interval->format('%i')>$minutes_to_add) { $value=$newList[$i]->time; //echo $value; echo $datesInMonth[(int)(date('j',$value)-1)]; //$oldValue=$datesInMonth[(date('j',$iTime[$i]->time)-1)]; //$newValue=$oldValue+1; //$datesInMonth[(date('j',$iTime[$i]->time)-1)]=$newValue; } } } $prevDate=$newList[$i]->time; $prevIp=$newList[$i]->ip; } Any ideas how to solve? Cheers, Link to comment https://forums.phpfreaks.com/topic/271037-setting-value-of-array-from-variable/ Share on other sites More sharing options...
Muddy_Funster Posted November 22, 2012 Share Posted November 22, 2012 sorry....what? Link to comment https://forums.phpfreaks.com/topic/271037-setting-value-of-array-from-variable/#findComment-1394439 Share on other sites More sharing options...
newbornultra Posted November 23, 2012 Author Share Posted November 23, 2012 sorry....what? Okay.. here's a var dump of an array. array(30) { [0]=> int(0) [1]=> int(0) [2]=> int(0) [3]=> int(0) [4]=> int(0) [5]=> int(0) [6]=> int(0) [7]=> int(0) [8]=> int(0) [9]=> int(0) [10]=> int(0) [11]=> int(0) [12]=> int(0) [13]=> int(0) [14]=> int(0) [15]=> int(0) [16]=> int(0) [17]=> int(0) [18]=> int(0) [19]=> int(0) [20]=> int(0) [21]=> int(0) [22]=> int(0) [23]=> int(0) [24]=> int(0) [25]=> int(0) [26]=> int(0) [27]=> int(0) [28]=> int(0) [29]=> int(0) } I want to get the value of the array element.. this is a snippet of my code: $valueInArray=(date('j',strtotime($value))-1).'<br>'; $cValueInArray=$datesInMonth[$valueInArray]; But when I execute it, I am getting a undefined index. Notice: Undefined index: 18 Notice: Undefined index: 14 Notice: Undefined index: 20 So in a nutshell for the first undefined index.. I am looking to get the value of datesInMonth array- element 18. Hope this makes sense now Edit: Fixed. I forgot to remove my '<br>' tags when debugging. Link to comment https://forums.phpfreaks.com/topic/271037-setting-value-of-array-from-variable/#findComment-1394579 Share on other sites More sharing options...
Christian F. Posted November 23, 2012 Share Posted November 23, 2012 What happened to date () and datetime's "t" format? t Number of days in the given month 28 through 31 Link to comment https://forums.phpfreaks.com/topic/271037-setting-value-of-array-from-variable/#findComment-1394600 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.