[thelist] [php] preg_replace text links?

kris burford kris at midtempo.net
Mon Nov 3 13:14:20 CST 2003


>One solution is simply to not use regular expressions to solve this 
>particular problem. I wrote up a blog entry on this technique (with sample 
>code) a while ago:
>
>http://simon.incutio.com/archive/2003/10/19/convertingLinks

hi simon,

that's a really nice explanation. thanks.

kris

<tip type="php" author="kris burford">

make sure if you're serializing arrays for posting via a form that you 
base64_encode/decode them. The serialized string otherwise contains 
quotations that will mess up your form and add/stripslashes doesn't work.

</tip>

<tip type="php" author="kris burford">

be careful when using array_unique as it *does not* sort out the key 
increment. so if you subsequently use the array in a for loop referenced by 
indices, you'll experience weird results!

instead use: (from user submitted comment on php.net)

function my_array_unique($array){
     $tmparr = array_unique($array);
     $i=0;
     foreach ($tmparr as $v) {
         $newarr[$i] = $v;
         $i++;
     }
     return $newarr;
}

</tip>



More information about the thelist mailing list