First question: For the case where the device_id is 2 the output is two, but any other case the output is still 2. Why is this?
if ($line == "IMEI 358998018395510\r\n"){
$device_id = 1;
}elseif($line == "IMEI 352924028650492\r\n"){
$device_id = 3;
}else {
$device_id = 2;
}
Second question: I would like to replace the else statement above with the following:
..
elseif ($line == "$GPVTG,0,T,0,M,0,N,0,K,A*23\r\n"){
$device_id = 2;
}
but the problem is that, the parser is faulting part of the string above picking out "$GPVTG" as undefined. Thought it should treat it as a whole string because it is in quotes?