Page 1 of 1
slit a string?
Posted: Sun Mar 05, 2006 6:36 pm
by vh81
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"
Posted: Sun Mar 05, 2006 6:49 pm
by Chris Corbyn
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:
Code: Select all
echo preg_replace('@(.*?):img:.*?:/img:(.*)@is', '$1$2', $string);
Have a look over:
viewtopic.php?t=33147
Posted: Sun Mar 05, 2006 8:11 pm
by vh81
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"
Posted: Sun Mar 05, 2006 11:02 pm
by feyd