function _unserialize($value) { if (strpos($value, '#') !== false) { $value = trim(preg_replace('/#(.+)$/', '', $value)); } if (preg_match('/^("(.*)"|\'(.*)\')/', $value, $matches)) { $value = (string) preg_replace('/(\'\'|\\\\\')/', "'", end($matches)); $value = preg_replace('/\\\\"/', '"', $value); } elseif (preg_match('/^\\[(.+)\\]$/', $value, $matches)) { // Inline Sequence // Take out strings sequences and mappings $explode = YAML_Parser::_escape($matches[1]); // Propogate value array $value = array(); foreach ($explode as $v) { $value[] = YAML_Parser::_unserialize($v); } } elseif (strpos($value, ':') !== false && !preg_match('/^{(.+)/', $value)) { // It's a map $array = explode(':', $value); $key = trim($array[0]); array_shift($array); $value = trim(implode(': ', $array)); $value = YAML_Parser::_unserialize($value); $value = array($key => $value); } elseif (preg_match("/{(.+)}\$/", $value, $matches)) { // Inline Mapping // Take out strings sequences and mappings $explode = YAML_Parser::_escape($matches[1]); // Propogate value array $array = array(); foreach ($explode as $v) { $array = $array + YAML_Parser::_unserialize($v); } $value = $array; } elseif (strtolower($value) == 'null' or $value == '' or $value == '~') { $value = null; } elseif (preg_match('/^[0-9]+$/', $value)) { $value = (int) $value; /*} elseif (in_array(strtolower($value), array('true', 'on', '+', 'yes', 'y'))) { $value = true; } elseif (in_array(strtolower($value), array('false', 'off', '-', 'no', 'n'))) { $value = false; */ } elseif (is_numeric($value)) { $value = (double) $value; } else { // Just a normal string, right? } return $value; }