Ok, I'm not very good with regex at the moment so could some one help me. What i need is Say i have $str = "Random text {func-test} more random text"; i need to use preg_replace to look for {func-*} in str and then return what ever * is. So say $func = preg_replace("/{func-*}/","*",$str); Hope that makes sense. Thanks
guessing your using this for a templating system? ... ill try and dig up what i did to solve the same problem i had
Ye this is for a templating system. @nice_swd, The code you posted does this say $text = "{func-test}blahblah{func-blah}"; it returns [0] = {func-test}, [1] = test. I need it to get [0] = test, [1] = blah. Thanks
<?php function get_funcs( $string ) { if( preg_match_all( "~\{func-(.*?)\}~", $string, $matches ) ) { return $matches[1]; } } print_r( get_funcs( "Random text {func-test} more random text and then {func-mine}" ) ); ?> PHP: