You are here

private static function Inline::dumpArray in Lockr 7.3

Dumps a PHP array to a YAML string.

Parameters

array $value The PHP array to dump:

int $flags A bit field of Yaml::DUMP_* constants to customize the dumped YAML string:

Return value

string The YAML string representing the PHP array

1 call to Inline::dumpArray()
Inline::dump in vendor/symfony/yaml/Inline.php
Dumps a given PHP variable to a YAML string.

File

vendor/symfony/yaml/Inline.php, line 284

Class

Inline
Inline implements a YAML parser/dumper for the YAML inline syntax.

Namespace

Symfony\Component\Yaml

Code

private static function dumpArray($value, $flags) {

  // array
  if (($value || Yaml::DUMP_EMPTY_ARRAY_AS_SEQUENCE & $flags) && !self::isHash($value)) {
    $output = [];
    foreach ($value as $val) {
      $output[] = self::dump($val, $flags);
    }
    return sprintf('[%s]', implode(', ', $output));
  }

  // hash
  $output = [];
  foreach ($value as $key => $val) {
    $output[] = sprintf('%s: %s', self::dump($key, $flags), self::dump($val, $flags));
  }
  return sprintf('{ %s }', implode(', ', $output));
}