Pogledajte određenu poruku
Staro 16. 07. 2014.   #1
Bojsi
član
Certified
 
Datum učlanjenja: 24.01.2007
Poruke: 92
Hvala: 1
798 "Hvala" u 15 poruka
Bojsi is on a distinguished roadBojsi is on a distinguished roadBojsi is on a distinguished roadBojsi is on a distinguished roadBojsi is on a distinguished roadBojsi is on a distinguished roadBojsi is on a distinguished road
Question PHP: Kada parser da "stane"

Pozdrav,

Imam jedan nadam se trivijalan problem. Izvinjavam se sto nisam mogao da smislim bolji naslov :(

Potrebno mi je da prodjem kroz sledeci string (uz pomoc PHP-a) i izdvojim kompletan tag:

Kd:
<php:page>
    <php:button>Test</php:button>
</php:page>
Odmah mi je na pamet palo sledece resenje:

Kd:
$patterns[] = "|\<php:(.*?)\>(.*?)\</php:(.*?)\>|e";		
$replaces[] = "\$this->createControl(\"$1\", \"$2\");";

return preg_replace($patterns, $replaces, $data);
Naravno, ono ne radi jer ce izvuci <php:page> a zavrsiti sa </php:button>

Da li mogu nekako da "fiksiram" drugu polovinu izraza (zatvaranje taga), da $3 mora da bude jednak $1 da bi stao sa parsiranjem, tako da stane tek kada opet naidje na </php:page>.

Mozda mogu da drugacije uradim i "izvucem" posebno button, page itd. ali se nadam da moze bolje (a i da naucim za kasnije).

Nadam se da sam dobro objasnio,

Hvala
Bojsi je offline   Odgovorite uz citat
180 članova zahvaljuje Bojsi za poruku:
aatavaolens, achelmeyerneilk, aczapiewskshain, aeharwardlaur, aennimancarm, aettermanmaudl, aionscalzconc, allen4jim, anorthfacemens, ardgraafwilfo, areraodel, aringascarl, arussianbran, asakamakimarc, aschoonovemaked, atyraanis, bapplebattery, brdvenablerayfo, budblak, celebritybrautk, cellocchiwino, cfacecheap, cfakecoach, cheapestcheapes, christianchrist, christianonsale, clgroschmurie, crygaliciazache, cstorecanada, ctarrickdied, dnhardwmrei, dokedziersrosen, dorflesnersalva, dswhiddendema, dyejidemcki, eabuechersophi, eangeruth, ebeisermarq, econeclar, edressesgreen, egressettfavi, ejerseynfl, emathiesokenn, emcqueenanto, emergelhous, encasteranto, enereebthom, ephonesbuy, erisselrosc, ershauerbric, esbissonetulyss, eskuhlemarco, fcheapfitsole, fhrentfrokhad, fnarufsabri, fuppfide, ggallagamerle, haughbobb, hhirschmabarr, hneprchalvale, hschherb, iaidimarc, iiantanidamarcp, iizzisamo, imandarinoveola, inejennieroxan, inorrixdarr, ioltmeierlynd, ionpanfilprest, istriblingmoshe, iyuriciclave, jnayjaso, jumijaim, kbierskiaria, kdlakrick, kdubykmajor, kelambkaruth, kmcvickermarj, ksaajokuthere, ktrackeisid, kwinskiiren, larholburt, lclachlandust, ldiellobryo, lemizelleshav, lemosellerobbi, ljagiellovinc, lmesserlymisty, locellelli, lriedldonn, luckwaltenels, meistmaikl, metwmper, meymeri, mlbaumrosse, mnamark, montclarmoncler, nbrabantarma, ncabeceiramilto, ncarpinonumb, nenningmick, nesimankricki, neveningparty, ngreenbackmarti, nielneversnatha, nieningshan, nincenorah, nkallenbemaur, nnvalentasun, norbinshan, nramanyjule, nsinapinkthoma, nsveentreva, ntasklandruper, nurdinmitc, nwiegandkatr, nydencesa, obertoerro, ocintoyongs, ofashionwigs, oiezarconepearl, okristoffflor, orangnowshaun, oronomark, ottleroehugo, pcheapface, pdekenipproger, piehlphilr, pioterpenflor, prdpala, qlspraquemars, racovaratimi, raynormarl, refnerrein, renmorebufo, rheldermajuli, riggeralen, rkunaroyal, rlamryan, rldogarrreyna, rlingeriebuy, rnnagaminewilbu, rnslerwend, rochnersungb, rtoontivernorbe, rumbersjoey, rverydresses, saccorsiamos, sceeashcons, sdressesdresses, selmasnico, shelmsdarr, sosephsenbust, sowsamd, stwiesarie, syerssand, tarnetcalv, taslattershaq, tatttobi, teastali, tewittgran, tezabielskyevet, tinregestevalen, tizattsolo, tmiretedad, tnhewittmarlo, tolyottjero, traditionaltrad, trestimm, tscristedema, udiscountbags, ueesaunanni, vienvert, wacheweloy, wkertaiwtiffany, yntyno, yrleyange, ytelajoyetonet, yusleycedr, zerganzazaneb