Salve a tutti, mi chiamo Daniele ed è il mio primo post.

Spero che qualcuno di voi mi possa aiutare. Ho una pagina in htm, dove gli utenti dovrebbero copiare il seguente testo tipico:
Codice PHP:
Computed route from PALERMO/PUNTA RAISI (LICJLIto ROMA/FIUMICINO (LIRFLI): 9 fixes238.8 nautical miles

Cruise altitude between FL290 
and FL390
LICJ 
(0.0nm) -SID-> LURON (40.7nm) -UM726-> DORAS (85.2nm) -UM726->
BEROL (121.6nm) -UM726-> ENSOT (141.4nm) -UM726-> PNZ (164.1nm) -UM726->
CIRCE (190.1nm) -UM726-> LAT (204.6nm) -STAR-> LIRF (238.8nm)

Details:

ID      FREQ   TRK   DIST   Coords                       Name/Remarks
LICJ             0      0   N38°10
'55.00" E013°05'58.00" PALERMO/PUNTA RAISI
LURON            1     41   N38°51'32.00" 
E013°06'57.00" LURON
DORAS          356     45   N39°35'
56.00" E013°03'36.00" DORAS
BEROL          356     36   N40°12
'17.00" E013°00'47.00" BEROL
ENSOT          356     20   N40°32'00.00" 
E012°59'15.00" ENSOT
PNZ     114.6  356     23   N40°54'
42.70" E012°57'26.70" PONZA
CIRCE           13     26   N41°20
'00.00" E013°05'00.00" CIRCE
LAT     111.2  329     15   N41°32'28.00" 
E012°55'05.00" LATINA
LIRF           297     34   N41°48'
01.00" E012°14'20.00" ROMA/FIUMICINO 
Tracks are magnetic, distances are in nautical miles. LICJ SID LURON UM726 LAT STAR LIRF

il codice htm della pagina è questa:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Nuova pagina 1</title>
<style>
body { font-family: Calibri, Times New Roman; font-size: 12; background:#FFFFFF; color:#005BAB; line-height:6px }
p { font-family: Calibri, Times New Roman; font-size: 12; background:#FFFFFF; color:#005BAB; line-height:6px; font-weight:bold }
input { font-family: Calibri, Times New Roman; font-size: 12; background:#FFFFFF; color:#F47320; line-height:6px; font-weight:bold }
</style>
</head>
<body>
<form ACTION="generazione_piani_di_volo3.php" METHOD=POST target="inferiore1">


Copy here routefinder text:

<textarea name='routefinder' rows=30 cols=120>Search the route in routefinder</textarea></p>
<input type="submit" value="Go to phase 3" name="b"><input type="reset" value="Reset">
</body>
</html>
E inserirlo in una pagina che prelevi opportunamente i dati e in particolare ottenere degli array fatti in questa maniera:

Array[1] = LICJ 0 0 N38°10'55.00" E013°05'58.00" PALERMO/PUNTA RAISI
Array[2] = LURON 1 41 N38°51'32.00" E013°06'57.00" LURON
Array[2] = DORAS 356 45 N39°35'56.00" E013°03'36.00" DORAS
e cosi via.

il codice php che elabora i dati è il seguente:
Codice PHP:
<?php

$routefinder
=($_REQUEST['routefinder']);
$routefinder str_replace('          '' '$routefinder);
$routefinder str_replace('         '' '$routefinder);
$routefinder str_replace('        '' '$routefinder);
$routefinder str_replace('       '' '$routefinder);
$routefinder str_replace('      '' '$routefinder);
$routefinder str_replace('     '' '$routefinder);
$routefinder str_replace('    '' '$routefinder);
$routefinder str_replace('   '' '$routefinder);
$routefinder str_replace('  '' '$routefinder);



// stampa tutto il testo
echo $routefinder;

// cerca ed estrae l'aeroporto di arrivo
$a strpos($routefinder') to ');
$destination_aerodrome substr($routefinder, -4$a);

// cerca ed estrae l'aeroporto di partenza
$b $a -8;
$departure_aerodrome substr($routefinder$b4);

// cerca ed estrae la distanza
$c strpos($routefinder'nautical miles');
$distance1 substr($routefinder$c 76);
$distance2 str_replace(','' '$distance1);
$distance3 ltrim($distance2);
$distance4 str_replace('.'','$distance3);

// cerca ed estrae la rotta
$d strpos($routefinder'Tracks are magnetic, distances are in nautical miles. ');
$route1 substr($routefinder$d 54);
$route2 str_replace($destination_aerodrome' '$route1);
$route3 str_replace($departure_aerodrome' '$route2);
$route4 str_replace('SID'' '$route3);
$route5 str_replace('STAR'' '$route4);
$route6 ltrim($route5);

// cerca ed estrae i vari punti
$e strpos($routefinder'Name/Remarks');
$f substr($routefinder$e 14);
$g strpos($f'Tracks are magnetic, distances are in nautical miles. ');
$h substr($f$g);
$i str_replace($h''$f);
$l str_replace('\r'' '$i);

?>


<?php
echo $a;
echo 
"destination_aerodrome=".$destination_aerodrome;
?>


<?php
echo $b;
echo 
"departure_aerodrome=".$departure_aerodrome;
?>


<?php
echo $c;
echo 
"distance=".$distance4;
?>


<?php
echo $d;
echo 
"route=".$route6;
?>


<?php
echo $e;
echo 
"routeeeeeeeeeee=".$l;
Come potete vedere dal codice ho provato a portare la stringa che definisce la variabile $l in un unica riga, ma senza risultati. Ho provato a fare anche un explode, ma nulla.

Come posso fare?

Saluti.
Daniele