function markup_urls ($text
{
// split the text into words
$words = preg_split'/([snr]+)/', $text, -1, PREG_SPLIT_DELIM_CAPTURE);
$text = ""
// iterate through the words
foreach$words as $word) {
// chopword = the portion of the word that will be replaced
$chopword = $word
$chopword = preg_replace'/^[^A-Za-z0-9]*/', '', $chopword);
if ($chopword <> '') {
// linkword = the text that will replace chopword in the word
$linkword''
// does it start with http://abc. ?
if (preg_match'/^(http://)[a-zA-Z0-9_]{2,}.*/', $chopword)) {
$chopword = preg_replace'/[^A-Za-z0-9/]*$/', '', $chopword);
$linkword = '<a href="'$chopword'" target="blank">'$chopword'</a>'
// does it equal abc.def.ghi ?
} else if (preg_match'/^[a-zA-Z]{2,}.([a-zA-Z0-9_]+.)+[a-zA-Z]{2,}(/.*)?/', $chopword)) {
$chopword = preg_replace'/[^A-Za-z0-9/]*$/', '', $chopword);
$linkword = '<a href="http://'$chopword'" target="blank">'$chopword'</a>'
// does it start with [email protected] ?
} else if (preg_match'/^[a-zA-Z0-9_.]+@([a-zA-Z0-9_]{2,}.)+[a-zA-Z]{2,}.*/', $chopword)) {
$chopword = preg_replace'/[^A-Za-z0-9]*$/', '', $chopword);
$linkword = '<a href="mailto:'$chopword'">'$chopword'</a>'
}
// replace chopword with linkword in word (if linkword was set)
if ($linkword <> '') {
$word = str_replace$chopword, $linkword, $word);
}
}
// append the word
$text = $text$word
}
return $text
}
Tag: Math
eXorithm – Execute Algorithm: Discuss Algorithm round_corners
round_corners    version 0.2    Round the corners of an image. Transparency and anti-aliasing are supported.Subject: integration error
niwdalg | posted: Dec 4, 2011 09:45 am | [reply] |
hi,
Can you help me in integrating this code? i am getting errors.
can you please give an example how this is integrated in image tag?
Subject: Image getting resized
Luciano Ziegler | posted: Nov 3, 2011 01:27 pm | [reply] |
Hi,
Thank you very much for your code. Finally I could get the transparency working on my thumbnails. The only problem is that the script is returned the images in a different size. I send thumbnails on 150px/150px and it returns an image with 214px/214px.
Any idea on how to fix this?
Thanks
Luciano Ziegler | posted: Nov 3, 2011 01:30 pm | [reply] |
My bad. It was my fault. Your script works perfect ๐
New Comment
eXorithm – Execute Algorithm: Discuss Algorithm address_elevation
address_elevation    version 0.2    Returns the elevation (in meters) above sea level for an address.
There are no comments yet
New Comment
eXorithm – Execute Algorithm: Discuss Algorithm unity
unity    version 1.2    Returns digit summation of any numerical value given for passkey (up to 14 digits in length)
There are no comments yet
New Comment
eXorithm – Execute Algorithm: View / Run Algorithm namePrefix
function namePrefix ($number
{
//Similar scrip in jquery https://jsfiddle.net/ayn_/z2677vs5/
$currentNum = $number
$currentNum = preg_replace'{/s|,|$|h}', '', $currentNum);
if ($currentNum > 999 && $currentNum < 999999) {
$newNum = ($currentNum / 1000);
$newNum = floor$newNum*100)/100 . 'k'
} else if ($currentNum > 999999) {
$newNum = ($currentNum / 1000000);
$newNum = floor$newNum*100)/100 . 'M'
} else {
$newNum = 'Error, number format is invalid'
}
return $newNum
}
eXorithm – Execute Algorithm: View / Run Algorithm invert_color
function invert_color ($color
{
$new = ''
for ($i=0;$i<3;$i++){
$c = 255 - hexdecsubstr$color,(2*$i),2));
$c = dechex$c);
$new .= (strlen$c) < 2) ? '0'$c : $c
}
return $new
}
eXorithm – Execute Algorithm: View / Run Algorithm lcm
function lcm ($a, $b
{
return abs$a$b)/gcd_euclid$a, $b);
}
eXorithm – Execute Algorithm: View / Run Algorithm next_prime
function next_prime ($start
{
$primes = -1;
for$i = $start+1; ; $i++)
{
$is_prime = true;
for$j = 2; $j < floor$i/2); $j++)
{
if(($i % $j) == 0)
{
$is_prime = false;
break
}
}
if ($is_prime
{
$prime = $i
break
}
}
return $prime
}
eXorithm – Execute Algorithm: Discuss Algorithm photobucket
photobucket    version 0.2    Gets all the pictures from a Photobucket album.
There are no comments yet
New Comment
eXorithm – Execute Algorithm: Discuss Algorithm draw_upc_barcode
draw_upc_barcode    version 0.3    Draw a barcode for a UPC number.
There are no comments yet
New Comment