07. juli 2002 - 14:36
Der er
17 kommentarer og 1 løsning
Klip væk
Jeg har i en variablen der hedder $row[text] en masse kode. Eksempel <body> <p>Hej med dig</p> <p>Jeg har her noget testkode</p> <p><?xml:space her er noget XML?> </p> </body> Nu vil jeg så godt have at den finder alle steder i koden hvor der står noget <?xml og sletter alt mellem <?xml og ?> så det kommer til at se sådan ud: <body> <p>Hej med dig</p> <p>Jeg har her noget testkode</p> <p> </p> </body> Håber i kan hjælpe mig! Daniel
Annonceindlæg fra Genetec
Du vil altså beholde <?xml og ?> ??
nej Klippe væk :D $row[text] = cut-everything-between("<?xml and ?>", $row[text]); :)
Ja, men du siger jo at du vi klippe alt mellem <?xml og ?> væk. Hvilken vil sige at du beholder disse to. Men ok, prøv dette: $data = "<p><?xml: space her er noget XML ?> </p>"; function cut($foo) { $foo = preg_replace("/<\?xml(.*?)\?>/is", "",$foo); return ($foo); } echo cut($data);
kan jeg så bare gøre sådan her $data = cut($data); `??
Source: function cut($foo) { $foo = preg_replace("/<\?xml(.*?)\?>/is", "",$foo); return ($foo); } $template = cut($template); fwrite ($out, "$template"); fclose ($out); men resultatet: <? :namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /> orginalt <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /?>
den har fjernet xml og ? til sidst..
prøvede at gøre sådan her: $template = preg_replace("/<\?(.*?)>/is", "",$template); fwrite ($out, "$template"); fclose ($out); resulterede i dette: <? :namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
07. juli 2002 - 15:37
#10
har lige testet din, den kan ikke cutte det. <html> <head> <title>Visdomnettet - World Wisdom Trust</title> <link href="css/stil.css" rel="stylesheet" type="text/css"> </style> </head> <body bgcolor="#FDFCEB" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0"> <table width="750" height="1" border="0" cellspacing="0" cellpadding="0"> <tr> <td colspan="3" height="1" valign="top"><?php include("include/top.php");?></tr> <tr> <td width="149" height="1" valign="top" class="vsortstreg"> <?php include("include/vmenu.php");?> </td> <td width="607" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="5"> <tr> <td bgcolor="#FFE7C6" valign="top" class="vsortstreg"><DIV align=left> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=3><FONT face="Times New Roman">Zxfggfc tvfytftyvyvtvytvy v y vyv<B style="mso-bidi-font-weight: normal">vtyytvyvtt<? :namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></B></FONT></FONT></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><B style="mso-bidi-font-weight: normal"><o:p><FONT face="Times New Roman" size=3> </FONT></o:p></B></P> <TABLE class=MsoTableGrid style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; BORDER-LEFT: medium none; BORDER-BOTTOM: medium none; BORDER-COLLAPSE: collapse; mso-border-alt: solid windowtext .5pt; mso-yfti-tbllook: 480; mso-padding-alt: 0cm 5.4pt 0cm 5.4pt; mso-border-insideh: .5pt solid windowtext; mso-border-insidev: .5pt solid windowtext" cellSpacing=0 cellPadding=0 border=1> <TBODY> <TR style="mso-yfti-irow: 0"> <TD style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: windowtext 1pt solid; WIDTH: 244.45pt; PADDING-TOP: 0cm; BORDER-BOTTOM: windowtext 1pt solid; BACKGROUND-COLOR: transparent; mso-border-alt: solid windowtext .5pt" vAlign=top width=326> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><B style="mso-bidi-font-weight: normal"><FONT face="Times New Roman">guy<o:p></o:p></FONT></B></P></TD> <TD style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: #ece9d8; WIDTH: 244.45pt; PADDING-TOP: 0cm; BORDER-BOTTOM: windowtext 1pt solid; BACKGROUND-COLOR: transparent; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt" vAlign=top width=326> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><B style="mso-bidi-font-weight: normal"><FONT face="Times New Roman">guy<o:p></o:p></FONT></B></P></TD></TR> <TR style="mso-yfti-irow: 1; mso-yfti-lastrow: yes"> <TD style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: #ece9d8; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: windowtext 1pt solid; WIDTH: 244.45pt; PADDING-TOP: 0cm; BORDER-BOTTOM: windowtext 1pt solid; BACKGROUND-COLOR: transparent; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt" vAlign=top width=326> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><B style="mso-bidi-font-weight: normal"><FONT face="Times New Roman">guy<o:p></o:p></FONT></B></P></TD> <TD style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: #ece9d8; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: #ece9d8; WIDTH: 244.45pt; PADDING-TOP: 0cm; BORDER-BOTTOM: windowtext 1pt solid; BACKGROUND-COLOR: transparent; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt" vAlign=top width=326> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><B style="mso-bidi-font-weight: normal"><FONT face="Times New Roman">gyu<o:p></o:p></FONT></B></P></TD></TR></TBODY></TABLE> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><B style="mso-bidi-font-weight: normal"><o:p><FONT face="Times New Roman" size=3> </FONT></o:p></B></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><B style="mso-bidi-font-weight: normal"><FONT size=3><FONT face="Times New Roman">Guygyu<o:p></o:p></FONT></FONT></B></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><B style="mso-bidi-font-weight: normal"><o:p><FONT face="Times New Roman" size=3> </FONT></o:p></B></P> <UL style="MARGIN-TOP: 0cm" type=disc> <LI class=MsoNormal style="MARGIN: 0cm 0cm 0pt; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt"><B style="mso-bidi-font-weight: normal"><FONT size=3><FONT face="Times New Roman">Huhiuhu<o:p></o:p></FONT></FONT></B></LI> <LI class=MsoNormal style="MARGIN: 0cm 0cm 0pt; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt"><B style="mso-bidi-font-weight: normal"><FONT size=3><FONT face="Times New Roman">Jjiojiojiojoi<o:p></o:p></FONT></FONT></B></LI> <LI class=MsoNormal style="MARGIN: 0cm 0cm 0pt; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt"><B style="mso-bidi-font-weight: normal"><FONT size=3><FONT face="Times New Roman">Kijopjiujiojiojoi<o:p></o:p></FONT></FONT></B></LI></UL> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><B style="mso-bidi-font-weight: normal"><o:p><FONT face="Times New Roman" size=3> </FONT></o:p></B></P></DIV></td> </tr> </table></td> <td width="124" class="sortstreg" valign="top"> <?php include("include/hmenu.php");?> <p> </p></td> </tr> <tr> <td> </td> <td> </td> <td> </td> </tr> </table> </body> </html> er den fulde kode og det er denne linje: <? :namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /> den ikke kan cutte
07. juli 2002 - 15:42
#11
Den tekst du lige har sendt, er det den du skal have cuttet det ud i?
07. juli 2002 - 15:44
#12
ja hele den tekst ligger i variablen $row[indhold] og du kan se jeg har nogle der hedder <?php i den, og de skal ikke væk, kun dem der hedder <? : og /> kan du klare det ?
07. juli 2002 - 15:49
#13
For s**** i og en i h******. Du startede jo med at skrive <?xml og ?> og det er jo det den søger efter.
07. juli 2002 - 16:10
#14
whatever: Har du endnu ikke vænnet dig til at folk her på eksperten ikke ved hvad de skal bruge når de spørger - sådan er det da ofte :-)
07. juli 2002 - 16:14
#15
tipsen > man bliver sku stadig gal, når man har brugt tid på dem.
07. juli 2002 - 16:41
#16
Hæhæ Sorry :D Sætter mine points op til 120.. da det ér dobbelt arbejde!?
07. juli 2002 - 16:53
#17
07. juli 2002 - 17:30
#18
Takker :D det virker nu
Vi tilbyder markedets bedste kurser inden for webudvikling