API15

JFilterOutput/stringURLSafe: Difference between revisions

From Joomla! Documentation

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...
 
m removing red link to edit, no existant pages
Line 3: Line 3:


<span class="editsection" style="font-size:76%;">
<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>[[Description:JFilterOutput/stringURLSafe|Edit Descripton]]<nowiki>]</nowiki>
<nowiki>[<! removed edit link to red link >]</nowiki>
</span>
</span>


{{Description:JFilterOutput/stringURLSafe}}
<! removed transcluded page call, red link never existed >


===Syntax===
===Syntax===
Line 50: Line 50:


<span class="editsection" style="font-size:76%;">
<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>[[SeeAlso:JFilterOutput/stringURLSafe|Edit See Also]]<nowiki>]</nowiki>
<nowiki>[<! removed edit link to red link >]</nowiki>
</span>
</span>
{{SeeAlso:JFilterOutput/stringURLSafe}}
<! removed transcluded page call, red link never existed >


===Examples===
===Examples===
Line 65: Line 65:
  format= ,,,
  format= ,,,
</dpl>
</dpl>
[[Category:Archived pages API15]]

Revision as of 17:19, 12 May 2013

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 edit link to red link >]

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

        // 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 edit link to red link >] <! removed transcluded page call, red link never existed >

Examples

<CodeExamplesForm />