|
@@ -136,39 +136,7 @@ class Arrays
|
|
|
*/
|
|
|
public function setPrivate($key, $value)
|
|
|
{
|
|
|
- preg_match_all("/(.*?)\[(.*?)\]/", $key, $match);
|
|
|
- $name = '';
|
|
|
- if (isset($match[1]) && isset($match[1][0])) {
|
|
|
- $name = $match[1][0];
|
|
|
- }
|
|
|
- $keys = $match[2];
|
|
|
- if ($name == '') {
|
|
|
- $name = $key;
|
|
|
- }
|
|
|
- if (empty($keys)) {
|
|
|
- $this->_private[$key] = $value;
|
|
|
- return $this->_private;
|
|
|
- }
|
|
|
- $private = array();
|
|
|
- $private = array_merge($private, $keys);
|
|
|
- $privates = null;
|
|
|
- if (is_array($value) || is_object($value)) {
|
|
|
- $array = str_replace('[\'\']', '[]', '$privates[\'' . join("']['", $private) . '\']=$value;');
|
|
|
- } else {
|
|
|
- $array = str_replace('[\'\']', '[]', '$privates[\'' . join("']['", $private) . '\']=\'' . $value . '\';');
|
|
|
- }
|
|
|
- eval($array);
|
|
|
- if (isset($this->_private[$name])) {
|
|
|
- if (!is_array($this->_private[$name])) {
|
|
|
- unset($this->_private[$name]);
|
|
|
- $this->_private[$name] = $privates;
|
|
|
- } else {
|
|
|
- $this->_private[$name] = array_merge_recursive($this->_private[$name], $privates);
|
|
|
- }
|
|
|
- } else {
|
|
|
- $this->_private[$name] = $privates;
|
|
|
- }
|
|
|
- return $this->_private;
|
|
|
+ return $this->set($key, $value);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -204,4 +172,14 @@ class Arrays
|
|
|
}
|
|
|
return $value;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取通过setPrivate key对应的值
|
|
|
+ *
|
|
|
+ * @param String $key
|
|
|
+ * @return Mix
|
|
|
+ */
|
|
|
+ public function getPrivate($key) {
|
|
|
+ return $this->get($key);
|
|
|
+ }
|
|
|
}
|