note 71684 rejected from function.preg-replace by nlopess

From: Date: Mon, 18 Dec 2006 13:14:51 +0000
Subject: note 71684 rejected from function.preg-replace by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-120744@lists.php.net to get a copy of this message
Note Submitter: jlockhar at vt dot edu ---- Ok, this little script is *supposed to* make my life easier by automatically generating links for matched strings, but it's not replacing properly with the $links element that corresponds with the $terms element. It's just putting "Array" in where the $links element should be. The examples for this function are atrocious for beginners, btw. <?php $what = $_POST['url']; $source = file_get_contents($what); $terms = explode(",", file_get_contents('engTerms.txt')); $links = explode(",", file_get_contents('engLinks.txt')); $whatsnew = preg_replace($terms, '<a href="' . $links . '">$0</a>', $source); echo $whatsnew; ?> Please note that '/' have been added to the terms and I've tried to reference the $terms key, but that seems to always eval to '0' so I get the first link in $links in all the replacements! UGH! This *SHOULD* be really easy to do!!!

« previous php.notes (#120744) next »