likeskoolaid Posted September 3, 2011 Share Posted September 3, 2011 I have two functions, one turns un-href links into working href links. <?php $reg_exUrl = "/(http|https|ftp|ftps)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?/"; ?> The other replaces an array of words into a different word. <?php $replace = array( 'Cat' => 'Dog', ); ?> This is how you echo both separately, the problem I'm having and need help with is combining both functions into one echo so both fixes apply to a single variable ($content). <?php echo str_replace_assoc($replace,$content); ?> <?php echo preg_replace(a$reg_exUrl, '<a href="'.$url[0].'" target="_blank" class="outboundlink" rel="nofollow">'.$url[0].'</a>', $content); ?> Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted September 3, 2011 Share Posted September 3, 2011 You mean like this? <?php $content = str_replace_assoc($replace,$content); echo preg_replace(a$reg_exUrl, '<a href="'.$url[0].'" target="_blank" class="outboundlink" rel="nofollow">'.$url[0].'</a>', $content); ?> Quote Link to comment Share on other sites More sharing options...
likeskoolaid Posted September 3, 2011 Author Share Posted September 3, 2011 Thank you for answering. Will your code still work if I'm using $content as a variable previously in the script? like $content='hello'; Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted September 3, 2011 Share Posted September 3, 2011 I don't see any reason it shouldn't, you're just reassigning the resulting output to the variable. Quote Link to comment Share on other sites More sharing options...
likeskoolaid Posted September 4, 2011 Author Share Posted September 4, 2011 You notice any errors in your code? Parse error: syntax error, unexpected T_VARIABLE in Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted September 4, 2011 Share Posted September 4, 2011 Looks like there's an 'a' that doesn't belong in there. It was in the code in the OP too, all I did was copy/paste it ... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.