> the current function been put in place replaces [f1253f] with a file,
for
> inside cms content , where 1253 is the key or the id of the filename
in
> the
> database , therefore to denote its an ftool they added f's around the
keys
> ,
> so maybe i could get away with [1253], what else i'm asking if
> preg_replace is
> more efficient over eregi_replace ?

Yeah, it is.

preg_match_all("/\[f([0-9]+)f\]/i",$string,$matches);

$matches will then contain the numbers you're looking for (in an array).
Read the file or whatever you need, then do another replace to put the
file contents in place of the code. 

If you read it like this:

$file['1234'] = "data from file 1234";
$file['3456'] = "data from file 3456";

You can use the following to replace the tags

preg_replace("/\[f([0-9]+)\]/ie",'$file[$1]',$string);

the last one is untested, but something like that works. The key is the
'e' modifier. If you know you're always going to have lower case 'f'
characters, then remove the 'i' modifier from each pattern.

---John Holmes...



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to