Difference between revisions of "JUtility/parseAttributes"
From Joomla! Documentation
< API15:JUtility
(New page: ===Description===
Method to extract key/value pairs out of a string with xml style attributes
<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>[[Description:JUtilit...) |
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>[<! removed edit link to red link >]</nowiki> |
</span> | </span> | ||
− | + | <! removed transcluded page call, red link never existed > | |
===Syntax=== | ===Syntax=== | ||
Line 54: | Line 54: | ||
<span class="editsection" style="font-size:76%;"> | <span class="editsection" style="font-size:76%;"> | ||
− | <nowiki>[< | + | <nowiki>[<! removed edit link to red link >]</nowiki> |
</span> | </span> | ||
− | + | <! removed transcluded page call, red link never existed > | |
===Examples=== | ===Examples=== | ||
Line 69: | Line 69: | ||
format= ,,, | format= ,,, | ||
</dpl> | </dpl> | ||
+ | [[Category:Archived pages API15]] |
Revision as of 13:58, 12 May 2013
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]
Method to extract key/value pairs out of a string with xml style attributes
[<! removed edit link to red link >]
<! removed transcluded page call, red link never existed >
Syntax[edit]
parseAttributes($string)
Parameter Name | Default Value | Description |
---|---|---|
$string | $string String containing xml style attributes |
Returns[edit]
array Key/Value pairs for the attributes
Defined in[edit]
libraries/joomla/utilities/utility.php
Importing[edit]
jimport( 'joomla.utilities.utility' );
Source Body[edit]
function parseAttributes( $string )
{
//Initialize variables
$attr = array();
$retarray = array();
// Lets grab all the key/value pairs using a regular expression
preg_match_all( '/([\w:-]+)[\s]?=[\s]?"([^"]*)"/i', $string, $attr );
if (is_array($attr))
{
$numPairs = count($attr[1]);
for($i = 0; $i < $numPairs; $i++ )
{
$retarray[$attr[1][$i]] = $attr[2][$i];
}
}
return $retarray;
}
[<! removed edit link to red link >] <! removed transcluded page call, red link never existed >
Examples[edit]
<CodeExamplesForm />