Pogledajte određenu poruku
Staro 16. 07. 2014.   #1
Bojsi
član
Certified
 
Datum učlanjenja: 24.01.2007
Poruke: 92
Hvala: 1
651 "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 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
171 članova zahvaljuje Bojsi za poruku:
aatavaolens, achelmeyerneilk, aczapiewskshain, aeharwardlaur, aennimancarm, aettermanmaudl, allen4jim, alovermannmiche, anorthfacemens, apelmanhora, aringascarl, arussianbran, asakamakimarc, aschoonovemaked, atyraanis, bapplebattery, brdvenablerayfo, btonburt, budblak, celebritybrautk, cellocchiwino, ceszucheldr, cfacecheap, cfakecoach, christianchrist, christianonsale, crygaliciazache, cstorecanada, cteciuccihenr, dgendant, dnhardwmrei, dorflesnersalva, dswhiddendema, dtepfundtvicen, dyejidemcki, eangeruth, ebeisermarq, ebuyaccessories, eclawgesrayf, econeclar, edressesgreen, egressettfavi, emathiesokenn, emcqueenanto, emergelhous, encasteranto, enhaldermjona, enpaynetruma, ephonesbuy, erexk, erisselrosc, ershauerbric, esalenike, esbardneymarku, esbissonetulyss, eskuhlemarco, etolefreemiles, fcheapfitsole, fuppfide, ggallagamerle, hhirschmabarr, hneprchalvale, hschherb, ihybhatiatimot, iizzisamo, imandarinoveola, inejennieroxan, inmonningequent, ioltmeierlynd, ionpanfilprest, irdfinninwinfo, istrahinarnu, istriblingmoshe, iyuriciclave, jnayjaso, jumijaim, kbierskiaria, kelambkaruth, kmcvickermarj, ksaajokuthere, ktrackeisid, larholburt, lartorellozadam, ldiellobryo, lemizelleshav, lemosellerobbi, lerolees, ljagiellovinc, lmesserlymisty, lriedldonn, luckwaltenels, metwmper, mlbaumrosse, mnachambevict, mnamark, montclarmoncler, nbereznycedr, nbrabantarma, ncabeceiramilto, neveningparty, nielneversnatha, nieningshan, nincenorah, nkallenbemaur, norbinshan, nramanyjule, nsinapinkthoma, nsveentreva, ntasklandruper, ntoscanoraym, nurdinmitc, nydencesa, obertoerro, ofashionwigs, oiezarconepearl, okristoffflor, orangnowshaun, oronomark, osjoem, ottleroehugo, pcheapface, piehlphilr, pioterpenflor, prdpala, qlspraquemars, racmurraylize, rahrexv, rdheminovemayna, refnerrein, renmorebufo, rheldermajuli, riggeralen, rkunaroyal, rlamryan, rldogarrreyna, rlingeriebuy, rnslerwend, rochnersungb, rtoontivernorbe, ruhnerrenek, rumbersjoey, sceeashcons, semerssonn, shelmsdarr, snbilkissmarli, sosephsenbust, srdbaisesanfo, ssourstyson, stwiesarie, syerssand, taslattershaq, tatttobi, teastali, tewittgran, tezabielskyevet, tinregestevalen, tmiretedad, tolyottjero, trestimm, tscristedema, tucholtzsamu, udiscountbags, ueesaunanni, uolyneuxmarc, wholesalephones, wholesaleprices, wkertaiwtiffany, yleraymard, yntyno, yrleyange, yusleycedr