I have an array that looks like this:
Array (
[0] => Array (
[START] => COI-COK
[RETURN] => CAI - DEL
)
[1] => Array (
[START] => COK - AMM
[RETURN] => CAI - DEL
)
)
I want to check if both 'start' and 'end' values of previous and current array are same or not. If not then, print some value. How can I do it?
This is my attempt:
foreach($data as $datas)
{
$old_start = $datas['START'];
$old_return = $datas['RETURN'];
...
if( ($old_start == $datas['START']) && ($old_return == $datas['RETURN']))
{
}
else
{
}
}
But it didn't work because all the time old_start
value will be equal to $datas['START']
.
print_r($data)
shows this output:
Array (
[0] => Array (
[Sl] => 2
[TRAVELDAY] => 2015-11-11
[RETURNDAY] => 2015-11-27
[START] => COI-COK
[RETURN] => CAI - DEL
)
[1] => Array (
[Sl] => 1
[TRAVELDAY] => 2015-11-11
[RETURNDAY] => 2015-11-27
[START] => COK - AMM
[RETURN] => CAI - DEL
)
)