i need some code to slit a string with some special tag
$needslit = "This is my string that contains :img: height=100 width=200 :/img: ... someone help me"; // 100, 200 isn't a fixed number, it can be any number!!
afterslit($needslit);
//$needslit: "This is my string that contians ... someone help me"
slit a string?
Moderator: General Moderators
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
What parts would you want returned?
:img:
some text here
:/img:
?
It sounds like you need a regular expression but I'm not sure exactly what you're asking

EDIT | I think I see what you're asking:
Have a look over: viewtopic.php?t=33147
:img:
some text here
:/img:
?
It sounds like you need a regular expression but I'm not sure exactly what you're asking
EDIT | I think I see what you're asking:
Code: Select all
echo preg_replace('@(.*?):img:.*?:/img:(.*)@is', '$1$2', $string);thanks, but your code doesn't do anything????
actually, i need a function that delete all [img] tag in a text string
for sample:
$string = This is my text [img:Blue hills.jpg,align=,width=700,height=525,vspace=0,hspace=0,border=1] it's contain many [img:rings.jpg,align=,width=400,height=325,vspace=0,hspace=0,border=1] i want to delete it";
i want affter processed $string will be "This is my text it's contain many i want to delete it". and two jpg file that included in that tag will be save in a array like this: $image[0] = "Blue hills.jpg" , $image[1] = "rings.jpg"
actually, i need a function that delete all [img] tag in a text string
for sample:
$string = This is my text [img:Blue hills.jpg,align=,width=700,height=525,vspace=0,hspace=0,border=1] it's contain many [img:rings.jpg,align=,width=400,height=325,vspace=0,hspace=0,border=1] i want to delete it";
i want affter processed $string will be "This is my text it's contain many i want to delete it". and two jpg file that included in that tag will be save in a array like this: $image[0] = "Blue hills.jpg" , $image[1] = "rings.jpg"
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
call preg_match_all() first, then preg_replace() with:
Code: Select all
#\[img:([^\]]+?)(?:,[^\]]+?)?\]#i