Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Sep 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Using two functions on one echo?

    I have two functions, one turns un-href links into working href links.


    PHP Code:
    <?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 Code:
    <?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 Code:
    <?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); ?>

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,537
    Thanks
    8
    Thanked 1,093 Times in 1,084 Posts
    Did you try this .. I'm just guessing here ...

    <?php echo preg_replace(a$reg_exUrl, '<a href="'.$url[0].'" rel="nofollow" target="_blank" class="outboundlink" rel="nofollow">'.$url[0].'</a>', str_replace_assoc($replace,$content)); ?>


    .


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •