API15

API15:JFilterOutput/stringURLSafe

From Joomla! Documentation

Revision as of 22: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)

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.

[Edit Descripton]

Template:Description:JFilterOutput/stringURLSafe

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

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

<CodeExamplesForm />