Jump to content
php.lv forumi

preg_split


ezis

Recommended Posts

Hei..

Doma taisit patauju skriptu ~ shaadi: [at]atbilde[/at][at]atbilde2[/at] tad ar preg split iegut: atbilde, atbilde2. un ar ciklu samest ieksh db atbilzu variantus. Bet problema ir ar preg_split patternu (laikam ta to sauc). kads butu pareizais patterns manam gadijumam? :?

Link to comment
Share on other sites

Ja jau izmanto tagus šādā formā [tags][/tags], tad varbūt uzreiz izmanto BBCode klases un miers?

Neesmu parliecinats, ka ar tam klasem vares panakt to, ko es velos.. btw, vesala klase prieksh viena aptauju skripta? oO

 

@Леший: uzmet erroru par delimiter.

Edited by ezis
Link to comment
Share on other sites

BUMP!

nuu kkas tads samurgojaas:

$str = "bla bla bla<at>atbilde</at> <at>atbilde2</at> bla bla blaa";
 $arr = preg_split("/<[at>]*[at\/]>/",$str);
 print_r($arr);

Array ( [0] => bla bla bla [1] => atbilde [2] => atbilde2 bla bla blaa )

Regular Expressions n00bs.. :\

Jautajums ir: kaa lai tiek valja no bla bla bla un bla bla blaa? man izdevas tikai tikt valja no atbilde un atbilde 2 :\

Link to comment
Share on other sites

preg_split() tev tur vispār nav vajadzīgs

$str = 'bla bla bla<at>atbilde</at> <at>atbilde2</at> bla bla blaa';
$mathces = array();
preg_match_all('/<at>(.+)<\/at>/U', $str, $matches);
print_r($matches[1]);

taisniba, nav gan vajadzigs ^^ sakuma gribeju taisit, lai butu bez tagiem, vienkarsi katru atbildi atdalot ar attiecigiem siboliem, bet tas likas nepiemeroti.

btw paldies.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...