I'm writing a content management system. The page admin enters content for a page and, when he enters a number surrounded by special characters, it's replaced by a database entry on the viewer's screen when parsed. To accomplish this in the parsing, I'm using preg_replace_callback(). However, I can't pass my database connection variable into the callback function, so it won't work. As a short-term workaround I'm just trying to make the database connection a global variable in this one instance and use it that way, but this is nothing but a sloppy kludge and not a good idea for the long-term.
Does anyone know how to solve my problem or even a different, better way of doing what I'm trying to do?