for example I am iterating class slots using foreach like
foreach ($result as $timeslot) {
$time=strtotime($timeslot);
$endTime = date("h:i A", strtotime('+' . $duration . ' minutes', $time));
echo date('h:i', strtotime($timeslot)) . '- ' . date('h:i A', strtotime($endTime));
}
I have another array foreach which iterates over booked_slot like
foreach($booked_slot as $slot){
$slot=strtotime($slot['start_time']);
echo "slot<br>";
}
The result of var_dump for $booked_slot is like:
[0]=>
object(app\modules\admin\models\OrderItem)#195 (10) {
["_attributes":"yii\db\BaseActiveRecord":private]=>
array(10) {
["id"]=>
int(128)
["user_id"]=>
int(73)
["location_id"]=>
int(2)
["instructor_id"]=>
int(16)
["order_id"]=>
int(54)
["cd_id"]=>
int(7)
["price"]=>
string(6) "300.00"
["date"]=>
string(10) "2018-04-12"
["start_time"]=>
string(8) "10:45:00"
["end_time"]=>
string(8) "10:55:00"
}
and the result of var_dump of $result is like
array(14) {
[0]=>
string(8) "10:05:00"
[1]=>
string(8) "10:15:00"
[2]=>
string(8) "10:25:00"
[3]=>
string(8) "10:35:00"
[4]=>
string(8) "10:45:00"
[5]=>
string(8) "10:55:00"
[6]=>
string(8) "11:05:00"
[7]=>
}
What I want is if $result have matching values for
$booked_slot[0]['start_time'] then that value is removed from the iteration of $result
To achieve this one option I tried is like
if(strtotime($timeslot) != $slot)
this works partly as where there is only one value in $result it works find, but if it has multiple values it works for only the last one.
The queries to generate the object array is like this:
$class_duration = ClassDuration::find()->where(['instructor_id' => $values['id']])->andwhere($cond)->all();
$booked_slot = OrderItem::find()->where(['instructor_id' => $values['id'],'date' =>$datec])->andwhere($cond)->all();