Jump to content

Recommended Posts

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,

Edited by newbornultra
Link to comment
https://forums.phpfreaks.com/topic/271037-setting-value-of-array-from-variable/
Share on other sites

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.

Edited by newbornultra
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.