• Home
  • Forum
  • Fare Web
  • PHP

Aiuto per problema stringa

  • Creatore Discussione Creatore Discussione dibdaniele
  • Data di inizio Data di inizio 5 Feb 2009
D

dibdaniele

Nuovo Utente
5 Feb 2009
1
0
0
  • 5 Feb 2009
  • #1
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:

HTML:
Computed route from PALERMO/PUNTA RAISI (LICJ, LI) to ROMA/FIUMICINO (LIRF, LI): 9 fixes, 238.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:
Citazione:

HTML:
<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">
<p>Copy here routefinder text:<br>
<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:
<?php

$routefinder=nl2br($_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, $b, 4);

// cerca ed estrae la distanza
$c = strpos($routefinder, 'nautical miles');
$distance1 = substr($routefinder, $c - 7, 6);
$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 = strpos($i, '\r');
$m = explode ("<br>", $l);
?>
<BR>
<?php
echo $a;
echo "destination_aerodrome=".$destination_aerodrome;
?>
<BR>
<?php
echo $b;
echo "departure_aerodrome=".$departure_aerodrome;
?>
<BR>
<?php
echo $c;
echo "distance=".$distance4;
?>
<BR>
<?php
echo $d;
echo "route=".$route6;
?>
<BR>
<?php
echo $e;
echo "routeeeeeeeeeee=".$m[1];
?>


Come potete vedere dal codice ho provato a esplodere la variabile $l per ottenere l'array che cercavo, ma senza risultati.

Come posso fare?

Saluti.
Daniele
 

borgo italia

Super Moderatore
Membro dello Staff
SUPER MOD
MOD
4 Feb 2008
16.044
150
63
PR
www.borgo-italia.it
  • 6 Feb 2009
  • #2
ciao
nono sono molto esperto, ma non è per caso che il problema siano i vari apici e doppi apici che hai nella stringa

prova ad aggiungere addslashes

$routefinder=nl2br(addslashes(($_REQUEST['routefinder']));
poi in fase di echo le togli con stripslashes

al massimo non funzia
 
Devi accedere o registrarti per poter rispondere.

Discussioni simili

S
Vi Chiedo Un Aiuto Per Risolvere Questo Problema:
  • signorscott
  • 17 Apr 2007
  • PHP
Risposte
2
Visite
1K
PHP 18 Apr 2007
signorscott
S
L
outpost firewall---aiuto per problema
  • liocorno
  • 4 Ott 2005
  • Windows e Software
Risposte
1
Visite
2K
Windows e Software 5 Ott 2005
open-think
D
problema!per favore aiuto
  • DANY(=
  • 9 Set 2004
  • PHP
Risposte
3
Visite
1K
PHP 10 Set 2004
jan267
E
Aiuto per query
  • Emanuele85
  • 25 Nov 2023
  • PHP
Risposte
8
Visite
3K
PHP 14 Dic 2023
marino51
I
aiuto urgente per thunderbird
  • ilprincipiante
  • 11 Ott 2022
  • Posta Elettronica
Risposte
0
Visite
1K
Posta Elettronica 11 Ott 2022
ilprincipiante
I
I
aiuto per outlook
  • ilprincipiante
  • 22 Giu 2022
  • Posta Elettronica
Risposte
0
Visite
1K
Posta Elettronica 22 Giu 2022
ilprincipiante
I
T
aiuto per trasformare un quiz fatto in JS in un quiz in JQUERY
  • theseo
  • 6 Gen 2022
  • jQuery
Risposte
0
Visite
3K
jQuery 6 Gen 2022
theseo
T
M
Fullcalendar in Codeigniter, un aiuto per la chiamata $ajax ?
  • mapa
  • 15 Nov 2021
  • jQuery
Risposte
0
Visite
3K
jQuery 15 Nov 2021
mapa
M
P
Aiuto per rendere un Bot Telegram Privato
  • PieRC
  • 13 Giu 2021
  • PHP
Risposte
1
Visite
3K
PHP 9 Ago 2021
odino
O
A
Aiuto per pagina php
  • AndreaCerre
  • 17 Feb 2021
  • PHP
Risposte
0
Visite
1K
PHP 17 Feb 2021
AndreaCerre
A
T
cercasi aiuto per file d1 (open-edge db)
  • theseo
  • 9 Ott 2020
  • Database
Risposte
0
Visite
1K
Database 9 Ott 2020
theseo
T
L
  • Bloccata
Aiuto per programma web php/mySQL
  • Ludo83
  • 29 Giu 2020
  • PHP
Risposte
2
Visite
2K
PHP 30 Giu 2020
Max 1
[Javascript] aiuto su jquery per calcolo altezze dom
  • claudio_lorenzo
  • 23 Nov 2019
  • Javascript
Risposte
1
Visite
2K
Javascript 23 Nov 2019
Tommy03
T
Aiuto per php7 e mysqli
  • tisana
  • 6 Apr 2019
  • PHP
Risposte
3
Visite
2K
PHP 6 Apr 2019
Max 1
T
mysql tutorial per importare tabelle access in mysql aiuto
  • twogate
  • 13 Mar 2019
  • MySQL
Risposte
2
Visite
2K
MySQL 13 Mar 2019
twogate
T
aiuto per sbloccare account instagram bannati
  • wildcity9
  • 14 Dic 2018
  • Social Media Marketing
Risposte
0
Visite
1K
Social Media Marketing 14 Dic 2018
wildcity9
A
Aiuto per configurare il banner di Iubenda su un sito in html
  • alessiapietralata
  • 1 Dic 2018
  • HTML e CSS
Risposte
0
Visite
1K
HTML e CSS 1 Dic 2018
alessiapietralata
A
S
[PHP] Aiuto creazione form php per completamento modello word
  • sagoch
  • 14 Apr 2018
  • PHP
Risposte
1
Visite
2K
PHP 16 Apr 2018
macus_adi
Z
[HTML] aiuto per visualizzazione su tablet
  • Zeitblom
  • 4 Gen 2018
  • Offerte e Richieste di Lavoro e/o Collaborazione
Risposte
6
Visite
2K
Offerte e Richieste di Lavoro e/o Collaborazione 19 Gen 2018
puntotoprinci
P
W
[PHP] Un aiuto per il mio primo "Multithread"
  • w_t
  • 23 Nov 2017
  • PHP
Risposte
0
Visite
2K
PHP 23 Nov 2017
w_t
W
Condividi:
Facebook X (Twitter) LinkedIn WhatsApp e-mail Condividi Link
  • Home
  • Forum
  • Fare Web
  • PHP
  • Italiano
  • Termini e condizioni d'uso del sito
  • Policy Privacy
  • Aiuto
  • Home
Community platform by XenForo® © 2010-2024 XenForo Ltd. | Traduzione a cura di XenForo Italia
Menu
Accedi

Registrati

  • Home
  • Forum
    • Nuovi Messaggi
    • Cerca...
  • Novità
    • Featured content
    • Nuovi Messaggi
    • Ultime Attività
X

Privacy & Transparency

We use cookies and similar technologies for the following purposes:

  • Personalized ads and content
  • Content measurement and audience insights

Do you accept cookies and these technologies?

X

Privacy & Transparency

We use cookies and similar technologies for the following purposes:

  • Personalized ads and content
  • Content measurement and audience insights

Do you accept cookies and these technologies?