JFilterOutput/stringURLSafe: Difference between revisions
From Joomla! Documentation
m clean up |
m preparing for archive only |
||
| Line 54: | Line 54: | ||
===Examples=== | ===Examples=== | ||
=== Code Examples === | |||
<dpl> | <dpl> | ||
noresultsheader=\n | noresultsheader=\n | ||
category=stringURLSafe | category=stringURLSafe | ||
category=JFilterOutput | category=JFilterOutput | ||
namespace=CodeExample | |||
category=MethodExample | category=MethodExample | ||
include=* | include=* | ||
Latest revision as of 01:40, 25 March 2017
Description
This method processes a string and replaces all accented UTF-8 characters by unaccented ASCII-7 "equivalents", whitespaces are replaced by hyphens and the string is lowercased.
<! removed transcluded page call, red link never existed >
Syntax
stringURLSafe($string)
| Parameter Name | Default Value | Description |
|---|---|---|
| $string | $input String to process |
Returns
string Processed string
Defined in
libraries/joomla/filter/filteroutput.php
Importing
jimport( 'joomla.filter.filteroutput' );
Source Body
function stringURLSafe($string)
{
//remove any '-' from the string they will be used as concatonater
$str = str_replace('-', ' ', $string);
$lang = &JFactory::getLanguage();
$str = $lang->transliterate($str);
// convert certain symbols to letter representation
$str = str_replace(array('&', '"', '<', '>'), array('a', 'q', 'l', 'g'), $str);
// remove any duplicate whitespace, and ensure all characters are alphanumeric
$str = preg_replace(array('/\s+/','/[^A-Za-z0-9\-]/'), array('-',''), $str);
// lowercase and trim
$str = trim(strtolower($str));
return $str;
}
<! removed transcluded page call, red link never existed >
Examples
Code Examples