0

i looked in google for several hours, but did not find any info on my question.

$elements[] = array('time1' => $time1, 'time2' => $time2, 'string1' => $string1, 'string2' => $string2, 'string3' => $string3, 'string4' => $string4);

i got array $elements, where i got written rows with code you see up from HTML table from page in internet. But i cant find the way, how can make filtering by time.

For example i want to use time interval 3 hours and get from array elements for next 3 hours.

I tried to use

while( $tmnw = date("H:i", strtotime('+3 hours'));  $tmnw < $elements['time2'] ) {

echo information from array;

}

but he throws error:

[12-Nov-2016 20:35:03] PHP Notice:  Trying to get property of non-object in filtering.php on line 15
[12-Nov-2016 20:35:03] PHP Notice:  Undefined index: time2 in filtering.php on line 41

time stores in array with simple_dom:

$time1= date( "H:i", strtotime( $row->find('td',0)->plaintext ) );
$time2= date( "H:i", strtotime( $row->find('td',1)->plaintext ) );

1 Answer 1

1

It is because your $elements is two-dimensional array and time2 is in second dimension. Also your cycle is an endless loop.

You will need something like

$tmnw = date("H:i", strtotime('+3 hours'));
foreach ($elements as $element) {
    if ($tmnw < $element['time2']) {
        echo 'info';
    }
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.