API15

JFilterOutput/stringURLSafe

From Joomla! Documentation

< API15:JFilterOutput
Revision as of 17:21, 22 March 2010 by Doxiki (talk | contribs) (New page: ===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 lowe...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

The "API15" namespace is an archived namespace. This page contains information for a Joomla! version which is no longer supported. It exists only as a historical reference, it will not be improved and its content may be incomplete and/or contain broken links.

Description[edit]

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.

[Edit Descripton]

Template:Description:JFilterOutput/stringURLSafe

Syntax[edit]

stringURLSafe($string)
Parameter Name Default Value Description
$string $input String to process

Returns[edit]

string Processed string

Defined in[edit]

libraries/joomla/filter/filteroutput.php

Importing[edit]

jimport( 'joomla.filter.filteroutput' );

Source Body[edit]

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);

        // 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;
}

[Edit See Also] Template:SeeAlso:JFilterOutput/stringURLSafe

Examples[edit]

<CodeExamplesForm />