Actions

API15

JArrayHelper/toString

From Joomla! Documentation

< API15:JArrayHelper
Replacement filing cabinet.png
This Namespace has been archived - Please Do Not Edit or Create Pages in this namespace. Pages contain information for a Joomla! version which is no longer supported. It exists only as a historical reference, will not be improved and its content may be incomplete.

[<! removed edit link to red link >]

<! removed transcluded page call, red link never existed >

Contents

Syntax

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

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

Examples

<CodeExamplesForm />