EGONick Posted July 16, 2008 Share Posted July 16, 2008 Hello there. I'm in need of some help. I'm trying to develop a function which searches a page and replaces a custom HTML tag with a content section from the database. I'm having a problem getting the var name of the content item to fetch it from the database. When it comes to expressions I'm pants. Here's my function up to now but, the variable fetched from the tag isn't passed through. function parse_content($content) { return preg_replace("/<content var=(.*)>/", get_object("content", '${1}'), $content); } Anyone got any idea's? Many thanks. Link to comment https://forums.phpfreaks.com/topic/115022-custom-tags-preg_replace/ Share on other sites More sharing options...
samshel Posted July 16, 2008 Share Posted July 16, 2008 did you check http://in2.php.net/manual/en/function.preg-replace-callback.php OR you can use preg_match first, here you get an array of matches which also contains your match for "()", that you can later use to replace. hth Link to comment https://forums.phpfreaks.com/topic/115022-custom-tags-preg_replace/#findComment-591487 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.