[eluser]easymind[/eluser]
Hi,
this is not really a codeingiter question, but help is often available here and I am developping in CI
The situation:
I have all kinds of texts inside my database. These texts have hyperlinks in them like:
Code:
<a href="!localfile:3,4">link to file</a>
The second digit (the 4) is the id of a file I have also stored in the databse. These files have tags or names also. So what I want is a search throught the text and a replacement where !localfile:3,4 becomes a real link. What I had in mind was:
Code:
preg_replace("/href=\"!localfile:\d,(\d)/",
'"href=\"".site_url()."downloadfile/".$this->getfiletagbyid($1)',
$pagetext);
But ofcourse this is not working since you cannot run methods from objects, only functions. I have looked into
preg_replace_callback and also
call_user_func, bot cannot get it working.
So I need to replace id's in a text with filetags and I do not want to put all files in an array (or something) first.
Hope somebody can help.
Brt