Viewing topic:preg_replace question
Page: 1
Topic post 04-08-2008 - 18:37
Hey jim,
I ran into a small snaffoo today. i'm trying to take a string like follows
Quote:

$string = "[Coment 1], [comment 2]";


for alittle bit more of an explanation:
http://www.talkphp.com/general/3212-pregreplace-minor-bbcoding.html

basicaly, i need alitle help understanding how to use preg_replace. i've looked on php.net but they don't exactly explain it righ....

Mind giving me a hand?

My AIM is Evulness, if you would rather speak in person

Thanks dude,
~Evul
Topic post 06-08-2008 - 15:04
Hey Mate,

Thats quite simple actually. You'll have to use preg_match_all.

From my head:

php
1
2
3
4
5
6

$string = '[poo] [stinks]';
 
preg_match_replace('[(.*?)]', $string, $matches);
 
// You can now use $matches the way you like (foreach recommended)
print_r($matches);
 


Havent tested it though.

©Copyrights Combined Minds. All rights reserved 2006 - 2008 : Disclaimer
Realized by www.Minna-Media.com