domain_url_encode

Versions
domain
domain_url_encode($string)

Simple function to clean strings for use in for example paths.

Code

./domain.module, line 2432

<?php
function domain_url_encode($string) {
  $string = drupal_strtolower($string);

  // Remove slashes.
  $string = str_replace('/', '', $string);

  // Reduce to the subset of ASCII96 letters and numbers - from Pathauto.
  $pattern = '/[^a-zA-Z0-9\/]+/ ';
  $string = preg_replace($pattern, '', $string);

  // Remove white space - from Pathauto.
  $string = preg_replace('/\s+/', '', $string);

  return $string;
}
?>

Contact

  • agentrickard [at] gmail [dot] com

Donations

My Amazon.com Wish List