1
I receive from a GPS a data line as in the first example below, and I have to treat it separating by comma in the same way as the second example:
Example Original Data
(027043011394BR00160422A2242.5954S04237.5592W000.40056470.000000000000L00000000)
Example of how the exit has to be (SEPARATION BY COMMA)
027043011394,BR00,160422,A,2242.5954S,04237.5592W,000.4,0056,70.0000,00000000L,00000000
And now Mount an array
[0] => 027043011394 - ID (identificação do dispositivo)
[1] => BR00 - comando
[2] => 160422 - em DATE (o formato yymmdd)
[3] => A -?
[4] => 2242.5954S - o Latitude
[5] => 04237.5592W - Longitude
[6] => 000.4 - Speed (nnn.n format)
[7] => 0056 - Time a (o formato hhmmssas a UTC)
[8] => 470.0 - Designação / rolamento (?)
[9] => 00000000L - a Elevation
[0] => 00000000 -
$ID = $parts[0];
echo $comando = $parts[1];
echo $date = $parts[2];
$A = $parts[3];
$lat = $parts[4];
$long = $parts[5];
$speed = $parts[6];
$time = $parts[7];
$eleleva = $parts[8];
$eleleva2 = $parts[9];
After placing the commas, just use the explode function to create the array with the data. The problem is to put the commas. Can you tell if this data is always the same size? I say, ID will always be 12 characters and so on?
– Clayderson Ferreira
That’s right Sizes don’t change
– Fabio Henrique