Jump to content
php.lv forumi

Recommended Posts

Posted

Bet tu jau arī prasi kā tikai izvadīt to linku. Kam tev vispār tie bbCode`i? Vari rakstīt:

$val = "[imgl]http://www.bildem.lv/pfiles/5964/maxpayne.png[/imgl]";
$search = array("[imgl]", "[/imgl]);
str_replace($search, "", $val);

 

Bet patiesībā tev droši vien vajadzētu skaīties preg_replace virzienā.

Posted (edited)

Doma ir tādā kas es saglabāju forumā custom tāgus ,tālāk jaunumos izvadu vissu parametrus priekš portāla skata ,piemēram mazbildīti ,meta tāgus utt..

 

<?php
$val = "xxx[imgl]http://www.bildem.lv/pfiles/5964/maxpayne.png[/imgl]yyy";
echo preg_replace('/(.*?)\[imgl\](.*?)\[\/imgl\](.*?)/', '$2', $val);
?>

Sanāk šādi bet nez kapēc yyy paliek :(

Edited by Wuu
Posted (edited)

Nepalīdz tāpat YY parādās :(

Nav kaut kādī reg tāgi satura sākums un beigas? Un vajadzētu visu tekstu izņemt ieskaitot jaunās līnijas.

<?php
$val = "xx \n x \n xxx [imgl]http://www.bildem.lv/pfiles/5964/maxpayne.png[/imgl] yy \n y";
echo preg_replace("/.*\[imgl\](.*)\[\/imgl\].*/U", "$1", $val);
?>

Edited by Wuu
Posted

Ja tu domā šādi tad tomēr nē :(

$val = "xx \n x \n xxx [imgl]http://www.bildem.lv/pfiles/5964/maxpayne.png[/imgl] yy \n y";
$tagToReplace = "'/\[imgl\](.*)\[\/imgl\]/iU'";
echo preg_replace($tagToReplace , "$1", $val);

Posted

ezis tavs kods izņēma tik imgl tagus

Beidzot atradu strādājošu variantu

			
$val = preg_replace('/\n/','',$val);
$val = preg_replace('/\r\n/','',$val);
$imgl = preg_replace("/.*\[imgl\](.*)\[\/imgl\].*/", "$1", $val);

Izdzēš visu kas ir apkārt un izvadi tikai kas ir iekš [imgl][/imgl] tāgiem

Tas ir marcis variants tik bez U galā!

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...