par
aly91 » 02 déc. 2014, 13:36
Bonjour je suis débutant en php,
Voici une ligne de mon fichier texte.
Ceci est une ligne : GRE_JEAN_JAURES;NW/UTRAN BTSEquipment/GRE_JEAN_JAURES Board/723467;10-04-2014 11:14:28;null;processing error;warning;active;softwareProgramError;TRDU/11 SOFTWARE DUMP;TRDU/11 SOFTWARE DUMP Specific Problem:TRDU/11 SOFTWARE DUMP, Cabinet:11, Shelf:10, Slot-position:11, AdditionalInformationFromNE:additionalInformation = { manufacturerInfoAscii = GP_TRDU Pmdz :The system was power-cycled. - Cause:1 - RRH F/W:_BI_RE_TE_TR_BAND01_FV_1.2.18 - HwRel:AB04 -
PEC:3JR21012AB - SN: GPCSTW1000501913 - MOD:TRDUBAND014C60W - SWver:UNB0814A110 } ;BTS_0002_00064;
Le but est de prendre le mot PEC: tout ce qui suit jusqu'au tiret en exemple ici
PEC:3JR21012AB . Et j'y arrive à l'aide de ces deux fonctions ci dessous. Le problème en est que parfois sur certaines lignes du fichier le mot a recherché est comme ça en exemple :
PE C:3JR21012AB avec un blanc au niveau du PEC. Et je voudrais à partir de ces deux fonctions, s'il voit
"PEC" ou
"PE C"( avec un blanc entre PE et le C), qu'il fasse le même traitement.
Merci de vos retours.
Bien cordialement.
function after ($this, $inthat)
{
if (!is_bool(strpos($inthat, $this)))
return substr($inthat, strpos($inthat,$this)+strlen($this));
};
function before ($this, $inthat)
{
return substr($inthat, 0, strpos($inthat, $this));
};
function between ($this, $that, $inthat)
{
return before ($that, after($this, $inthat));
};
$sLine = "GRE_JEAN_JAURES;NW/UTRAN BTSEquipment/GRE_JEAN_JAURES Board/723467;10-04-2014 11:14:28;null;processing error;warning;active;softwareProgramError;TRDU/11 SOFTWARE DUMP;TRDU/11 SOFTWARE DUMP Specific Problem:TRDU/11 SOFTWARE DUMP, Cabinet:11, Shelf:10, Slot-position:11, AdditionalInformationFromNE:additionalInformation = { manufacturerInfoAscii = GP_TRDU Pmdz :The system was power-cycled. - Cause:1 - RRH F/W:_BI_RE_TE_TR_BAND01_FV_1.2.18 - HwRel:AB04 - PEC:3JR21012AB - SN: GPCSTW1000501913 - MOD:TRDUBAND014C60W - SWver:UNB0814A110 } ;BTS_0002_00064;";
echo 'PEC'.between('PEC','-',$sLine);
$sLineSecond = "CINQ_AVENUES;NW/UTRAN BTSEquipment/CINQ_AVENUES Board/81;10-04-2014 15:47:45;null;processing error;warning;active;softwareProgramError;CCM/81 SOFTWARE DUMP;CCM/81 SOFTWARE DUMP Specific Problem:CCM/81 SOFTWARE DUMP, Cabinet:0, Shelf:0, Slot-position:81, AdditionalInformationFromNE:additionalInformation = { manufacturerInfoAscii = Uptime : 52 days 04:05:43.Sequence num: 32.Thread name : tCpManager.Thread ID : 0x36ddb4b0.Error number: 0.Signal : 11.State and Misc Registers:. TRAP : 00000300. MSR : 0202d200. DAR : 00000096. DSISR: 00800000. IAR : 0d39299c. SP : 36dda7e0. LR : 0d391810. CR : 24004442. CTR : 0cdb1d60. XER : 00000000.Traceback:. 0d39299c. 0d3e1a80. 0d407f64. 0 f79ef74. 0d47c590. 0d47d00c. 0f822178. 0fd22ccc. 30028d8c. 0ff25a90. 00000000. 00000000. 00000000. 00000000. 00000000 . 00000000. 00000000. 00000000. 00000000. 00000000.HwRel:CA01 - PEC:3JR20073BC - SN:YP14160B64C - MOD:MOD:eCCM-U_GE - SWver :UNB0814A110 } ;BTS_0002_00001;";
echo 'PEC'.between('PEC','-',$sLineSecond);
Bonjour je suis débutant en php,
Voici une ligne de mon fichier texte.
Ceci est une ligne : GRE_JEAN_JAURES;NW/UTRAN BTSEquipment/GRE_JEAN_JAURES Board/723467;10-04-2014 11:14:28;null;processing error;warning;active;softwareProgramError;TRDU/11 SOFTWARE DUMP;TRDU/11 SOFTWARE DUMP Specific Problem:TRDU/11 SOFTWARE DUMP, Cabinet:11, Shelf:10, Slot-position:11, AdditionalInformationFromNE:additionalInformation = { manufacturerInfoAscii = GP_TRDU Pmdz :The system was power-cycled. - Cause:1 - RRH F/W:_BI_RE_TE_TR_BAND01_FV_1.2.18 - HwRel:AB04 - [b]PEC:3JR21012AB [/b]- SN: GPCSTW1000501913 - MOD:TRDUBAND014C60W - SWver:UNB0814A110 } ;BTS_0002_00064;
Le but est de prendre le mot PEC: tout ce qui suit jusqu'au tiret en exemple ici [b]PEC:3JR21012AB [/b]. Et j'y arrive à l'aide de ces deux fonctions ci dessous. Le problème en est que parfois sur certaines lignes du fichier le mot a recherché est comme ça en exemple :[b]PE C:3JR21012AB [/b] avec un blanc au niveau du PEC. Et je voudrais à partir de ces deux fonctions, s'il voit [b]"PEC"[/b] ou [b]"PE C"[/b]( avec un blanc entre PE et le C), qu'il fasse le même traitement.
Merci de vos retours.
Bien cordialement.
[php]
function after ($this, $inthat)
{
if (!is_bool(strpos($inthat, $this)))
return substr($inthat, strpos($inthat,$this)+strlen($this));
};
function before ($this, $inthat)
{
return substr($inthat, 0, strpos($inthat, $this));
};
function between ($this, $that, $inthat)
{
return before ($that, after($this, $inthat));
};
$sLine = "GRE_JEAN_JAURES;NW/UTRAN BTSEquipment/GRE_JEAN_JAURES Board/723467;10-04-2014 11:14:28;null;processing error;warning;active;softwareProgramError;TRDU/11 SOFTWARE DUMP;TRDU/11 SOFTWARE DUMP Specific Problem:TRDU/11 SOFTWARE DUMP, Cabinet:11, Shelf:10, Slot-position:11, AdditionalInformationFromNE:additionalInformation = { manufacturerInfoAscii = GP_TRDU Pmdz :The system was power-cycled. - Cause:1 - RRH F/W:_BI_RE_TE_TR_BAND01_FV_1.2.18 - HwRel:AB04 - PEC:3JR21012AB - SN: GPCSTW1000501913 - MOD:TRDUBAND014C60W - SWver:UNB0814A110 } ;BTS_0002_00064;";
echo 'PEC'.between('PEC','-',$sLine);
$sLineSecond = "CINQ_AVENUES;NW/UTRAN BTSEquipment/CINQ_AVENUES Board/81;10-04-2014 15:47:45;null;processing error;warning;active;softwareProgramError;CCM/81 SOFTWARE DUMP;CCM/81 SOFTWARE DUMP Specific Problem:CCM/81 SOFTWARE DUMP, Cabinet:0, Shelf:0, Slot-position:81, AdditionalInformationFromNE:additionalInformation = { manufacturerInfoAscii = Uptime : 52 days 04:05:43.Sequence num: 32.Thread name : tCpManager.Thread ID : 0x36ddb4b0.Error number: 0.Signal : 11.State and Misc Registers:. TRAP : 00000300. MSR : 0202d200. DAR : 00000096. DSISR: 00800000. IAR : 0d39299c. SP : 36dda7e0. LR : 0d391810. CR : 24004442. CTR : 0cdb1d60. XER : 00000000.Traceback:. 0d39299c. 0d3e1a80. 0d407f64. 0 f79ef74. 0d47c590. 0d47d00c. 0f822178. 0fd22ccc. 30028d8c. 0ff25a90. 00000000. 00000000. 00000000. 00000000. 00000000 . 00000000. 00000000. 00000000. 00000000. 00000000.HwRel:CA01 - PEC:3JR20073BC - SN:YP14160B64C - MOD:MOD:eCCM-U_GE - SWver :UNB0814A110 } ;BTS_0002_00001;";
echo 'PEC'.between('PEC','-',$sLineSecond);
[/php]