PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
function addLinks(){
preg_replace("text", "<a href=\"http://www.example.com/\">text</a>", $spun, 1);
}
Gives me the error message "Delimiter must not be alphanumeric or backslash" - what am I doing wrong here? If it makes a difference, this function goes through a chunk of text and replaces certain words with a hyperlinked version of itself.
The first argument is the pattern to search for. The pattern needs 'delimiters' at the beginning and the end. Commonly a forward slash (/) is used as a delimiter. So - "/text/" , not "text".
Ok, perhaps I'm doing something else wrong then...I don't get the error message now that I've made that change, but I'm getting no output. When I do it outside of a function, it works fine. Do you see any mistakes here? (by the way, I'm going to drop preg_replace and use str_replace instead)