andre Posted October 21, 2003 Report Posted October 21, 2003 karoche, ir taads teksts : "asdasdas <!#MODULE:asd#>asdf asdf asdf <!#MODULE:fds#> asd asd as <!#MODULE:iuy#> sada" uztaisiit funkciju vai skriptu, kas beigaas izdariis luuk taaaa (tipa lai rezultaats buutu taads): "asdasdas ".$asd."asdf asdf asdf ".$fds." asd asd as ".$iuy." sada"
Roze Posted October 21, 2003 Report Posted October 21, 2003 Nu vienkaarshakajaa un brutaakalajaa variantaa.. $string = "asdasdas <!#MODULE:asd#>asdf asdf asdf <!#MODULE:fds#> asd asd as <!#MODULE:iuy#> sada"; $string = str_replace('<!#MODULE:','".$',$string); $string = str_replace('#>','."',$string);
BigUgga Posted October 21, 2003 Report Posted October 21, 2003 ja vaig ieguut tieshi "asdasdas ".$asd."asdf asdf asdf ".$fds." asd asd as ".$iuy." sada" izmanto Roze doto piemeeru, vai arii, ja gribas buut advanceetam ;) tad <? $patt = '/<!#MODULE:(.*)#>/iU'; $repl = '".$$1."'; $string = preg_replace($patt, $repl, $string); ?> ja vaig jau ar saliktiem visiem mainiigajiem, tad <? $patt = '/<!#MODULE:(.*)#>/iUe'; $repl = '$$1'; $string = preg_replace($patt, $repl, $string); ?>
andre Posted October 22, 2003 Author Report Posted October 22, 2003 ideja ir taada, ka jaatorod stringaaa <#MODULE:asd#> jaanoslasa,kas ir peec MODULE: (<#MODULE:?#>) un pirms "#>" dotajaa variantaa ?=asd un tad jaaieliek mainiigais $$temp. kur $temp="asd" (tas kas sekoja peec "MODULE:")
andre Posted October 22, 2003 Author Report Posted October 22, 2003 man liekas ka tas jaadara ar preg_match('/<#MODULE:?#>/i',"$string", $matches); tikai es to nosaciijumu nevaru uzrakstiit :(
BigUgga Posted October 23, 2003 Report Posted October 23, 2003 taatad, ja ir dots 'tuci buci <#MODULE:asd#> cuci luci' un $asd = 'blabla' tad rezultaatam jaabuut 'tuci buci blabla cuci luci' ? jebshu rezultaatam jaabuut 'tuci buci <#MODULE:blabla#> cuci luci'
andre Posted October 25, 2003 Author Report Posted October 25, 2003 tieshi to arii vajag, ko tu teici taatad, ja ir dots 'tuci buci <#MODULE:asd#> cuci luci' un $asd = 'blabla' tad rezultaatam jaabuut 'tuci buci blabla cuci luci' ?
BigUgga Posted October 25, 2003 Report Posted October 25, 2003 es gan jautaaju 2as dazhaadas lietas, bet nu lai paliek. liekas, ka nemaz tik ljoti shitas risinaajums nav vajadziigs, jo manaa pirmajaa postaa jau tas ir. (skat koda 2o variantu)
Recommended Posts