JArrayHelper/toString: Difference between revisions
From Joomla! Documentation
m clean up |
m preparing for archive only |
||
| Line 64: | Line 64: | ||
===Examples=== | ===Examples=== | ||
=== Code Examples === | |||
<dpl> | <dpl> | ||
noresultsheader=\n | noresultsheader=\n | ||
category=toString | category=toString | ||
category=JArrayHelper | category=JArrayHelper | ||
namespace=CodeExample | |||
category=MethodExample | category=MethodExample | ||
include=* | include=* | ||
Latest revision as of 01:19, 25 March 2017
<! removed transcluded page call, red link never existed >
Syntax
static toString($array=null, $inner_glue= '=', $outer_glue= ' ', $keepOuterKey=false)
| Parameter Name | Default Value | Description |
|---|---|---|
| $array | null | |
| $inner_glue | '=' | |
| $outer_glue | ' ' | |
| $keepOuterKey | false |
Defined in
libraries/joomla/utilities/arrayhelper.php
Importing
jimport( 'joomla.utilities.arrayhelper' );
Source Body
static function toString($array = null, $inner_glue = '=', $outer_glue = ' ', $keepOuterKey = false)
{
$output = array();
if (is_array($array))
{
foreach ($array as $key => $item)
{
if (is_array ($item))
{
if ($keepOuterKey) {
$output[] = $key;
}
// This is value is an array, go and do it again!
$output[] = JArrayHelper::toString($item, $inner_glue, $outer_glue, $keepOuterKey);
}
else {
$output[] = $key.$inner_glue.'"'.$item.'"';
}
}
}
return implode($outer_glue, $output);
}
<! removed transcluded page call, red link never existed >
Examples
Code Examples