I need some helps to compare some arrays with php, basically I have two arrays (mission and employee) :
Array mission :
Array(
[0] => Array (
[days] => Monday
[hours] => 1,0,0,0,0,0
)
[1] => Array
(
[days] => Tuesday
[hours] => 1,1,0,0,0,1
)
)
Array employee :
Array(
[0] => Array (
[days] => Monday
[hours] => 1,0,0,0,0,0
)
[1] => Array
(
[days] => Tuesday
[hours] => 1,1,0,0,0,1
)
)
[1] => Array
(
[days] => Wednesday
[hours] => 1,1,0,0,0,1
)
)
The aim is to compare if employee is available for a mission, it means if employee is available (above case) Monday and Tuesday with included hours to work (1 and 0 represents hours and position of each item is very important).
Firstly employee is not available if number of mission days is superior to employee day :
foreach ($mission as $m) {
# code...
$m_days[] = $m['days'];
foreach ($employee as $e) {
$e_days[] = $e['days'];
}
$i++;
}
/// First condition if m_days > e_days so valid
$valid = (sizeof($m_days) > sizeof($e_days)) ? true : false;
After that I have no idea to compare if employee is at least available for mission hours, for example if mission is a Monday with hours : 1,1,0,0,0,1 and employee is free for Monday with hours : 1,1,1,0,0,1 he can take the mission, but if he is available Monday with hours : 1,0,0,0,0,1 he cannot take the mission.
With array_diff it is not working as demonstrated here
Could you help me please ? Thank you.
Notice: Array to string conversion in [...][...] on line 5
Notice: Array to string conversion in [...][...] on line 5
Array ( ) – Rahajason Jan 20 '17 at 17:14