Autor | Zpráva | ||
---|---|---|---|
Cup Profil |
#1 · Zasláno: 13. 9. 2009, 19:45:52 · Upravil/a: Cup
$vysledek = str_replace('<br />', '<br>', $vysledek); // sjednotime si odentrovani... $pole=explode("<br>", $vysledek);//rozdělíme na řádky, $maz_br = 0; foreach ($pole as $cast) { // PROJDU RADKY if(strpos($cast,"<pre>")!==false){$maz_br = 1;} // kdyz bude na radku PRE tak zacnu mazat mezery if(strpos($cast,"</pre>")!==false){$maz_br = 0; } // kdyz tam bude ukonceni pre tak prestanu mazat mezery if($maz_br == 1)$cast = str_replace('<br>', ' ', $cast); // mazu mezery } $vysledek = implode(" ",$pole); je to kousíček kódu ale nefunguje mi to ... smažou se mi všechny mezery nebo žádné nevidíte tam nějakej kiks? |
||
Cup Profil |
#2 · Zasláno: 13. 9. 2009, 20:00:20 · Upravil/a: Cup
v podstatě mi jde o toto
vstupní řetězec Lorem Ipsum is<br /> simply dummy text of the printing<br /> <pre> and typesetting industry. Lorem I<br /> psum has been the industry's standard<br /> dummy text ever since the 1500s, when <br /> an unknown printer took a galley of type <br /> </pre>and scrambled it to make a type<br /> specimen book. It has survived not o<br /> nly five centuries, but also the leap into<br /> electronic typesetting, remaining essentia<br /> výstupní řetězec Lorem Ipsum is<br /> simply dummy text of the printing<br /> <pre> and typesetting industry. Lorem I psum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type </pre>and scrambled it to make a type<br /> specimen book. It has survived not o<br /> nly five centuries, but also the leap into<br /> electronic typesetting, remaining essentia<br /> // odřádkování mezi značkami pre ve výstupním řetězci chybí Nevíte prosím někdo jak ten kousek kódu poladit aby mě to jelo? |
||
DJ Miky Profil |
#3 · Zasláno: 13. 9. 2009, 20:08:22
Smysl toho skriptu má být odstranění všech <br> mezi <pre> a </pre>?
Pak by to šlo vyřešit regulárními výrazy: $vysledek = preg_replace('@(<pre>)(.+)(</pre>)@uies', "'\\1'.str_replace(array('<br>','<br />'),'','\\2').'\\3'", $vysledek); |
||
SwimX Profil |
#4 · Zasláno: 13. 9. 2009, 22:41:30
DJ Miky
kódy v <pre> se zobraí tak jak jsou napsány v kódu, takže bych tvůj regulár s dovolením upravil: $vysledek = preg_replace('@(<pre>)(.+)(</pre>)@uies', "'\\1'.str_replace(array('<br>','<br />'),'\r\n','\\2').'\\3'", $vysledek); |
||
Cup Profil |
#5 · Zasláno: 13. 9. 2009, 22:53:22 · Upravil/a: Cup
DJ Miky,SwimX,
pánové díky za pomoc původně jsem to chtěl taky řešit regulerním výrazem ale zjistil sem že na to nemam tak sem to chtěl obejít... díky |
||
Cup Profil |
#6 · Zasláno: 13. 9. 2009, 23:01:26
problem, regulerni vyraz odstranil <br /> ale nahradil to nepsanymi mezerami ... coz je ve vysledku toto
vstupní řetězec Lorem Ipsum is<br /> simply dummy text of the printing<br /> <pre> and typesetting industry. Lorem I<br /> psum has been the industry's standard<br /> dummy text ever since the 1500s, when <br /> an unknown printer took a galley of type <br /> </pre>and scrambled it to make a type<br /> specimen book. It has survived not o<br /> nly five centuries, but also the leap into<br /> electronic typesetting, remaining essentia<br /> výstupní řetězec Lorem Ipsum is<br /> simply dummy text of the printing<br /> <pre> and typesetting industry. Lorem I psum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type </pre>and scrambled it to make a type<br /> specimen book. It has survived not o<br /> nly five centuries, but also the leap into<br /> electronic typesetting, remaining essentia<br /> nevidíte tam ještě někde chybku? ... díky |
||
Cup Profil |
#7 · Zasláno: 13. 9. 2009, 23:04:31 · Upravil/a: Cup
pohoda ... vyresil jsem to ... .) ale bez vas ani ránu .. díky ...
$vysledek = preg_replace('@(<pre>)(.+)(</pre>)@uies', "'\\1'.str_replace(array('<br>','<br />'),' ','\\2').'\\3'", $vysledek); mezera u str_replace |
||
DJ Miky Profil |
#8 · Zasláno: 14. 9. 2009, 16:18:13
SwimX
„kódy v <pre> se zobraí tak jak jsou napsány v kódu“ Právě proto... Je tam <br> i \n, takže odstraněním <br> ti tam pořád zbyde odřádkování (což pak ve výsledku nic nevyřeší, viz #6) Cup Ta mezera tam ani být nemusí, stačí to, co jsem poslal já (bez mezery) a ne SwimX. |
||
Časová prodleva: 15 let
|
0