Browsing the blog archives for September, 2008.

Old code.

Code, php

I love coming across old code *cough* garbage *cough*

The purpose of this was to take a title, and create something url safe and in the fashion a client was wanting. The first function was old code, so don’t blame me.

function cleanUrl($url)
{
  $find =        array('/--/', '/ - /','/ /', '/!/', '/"/', "/'/", '/--/');
  $replace =    array('-', '-', '-', '', '', '', '-');

  $result = strtr($url, "`~@#$%^&*()_=+|[]{};:,./<>?", "---------------------------");

  return strtolower(preg_replace($find, $replace, strip_tags(stripslashes(trim($result)))));
}

Isn’t it horrible?

I rewrote the function to…

function cleanUrl($url)
{
  $url = strtolower($url);

  $url = preg_replace("/[^a-z0-9\s+]/", '', $url);
  $url = preg_replace("/[\s]{1,}/", '-', $url);

  return $url;
}

That makes me happier.

No Comments

Lazy day

Personal

Today is rainy and full of nastiness. (Thanks Ike!)

I should have gotten out to play disc golf while the weather was beautiful, I just didn’t feel too hot.

Called my sister Meagan a few times, her voicemail is picking up so I’m yelling in a demonic sounding voice and hanging up. Hopefully it freaks them out a bit. If not, well, no loss.

Work is going well, moving forward on some things and looking good.

Snapped a great picture of my brother in law, and his wifes brother being dorks. Put it up on my facebook in the mobile uploads.

This turned into more of a journal entry, rock on.

No Comments