You are here

public function Form::getPhpValues in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/dom-crawler/Form.php \Symfony\Component\DomCrawler\Form::getPhpValues()

Gets the field values as PHP.

This method converts fields with the array notation (like foo[bar] to arrays) like PHP does.

Return value

array An array of field values.

File

vendor/symfony/dom-crawler/Form.php, line 140

Class

Form
Form represents an HTML form.

Namespace

Symfony\Component\DomCrawler

Code

public function getPhpValues() {
  $values = array();
  foreach ($this
    ->getValues() as $name => $value) {
    $qs = http_build_query(array(
      $name => $value,
    ), '', '&');
    if (!empty($qs)) {
      parse_str($qs, $expandedValue);
      $varName = substr($name, 0, strlen(key($expandedValue)));
      $values = array_replace_recursive($values, array(
        $varName => current($expandedValue),
      ));
    }
  }
  return $values;
}