- function toarray($array, $var, $content = "") {
- foreach ( $array as $key => $value ) {
- if (is_array ( $value )) {
- $content .= $this->__array ( $value, "" . $var . "[\\"" . $key . "\\"]" );
- } else {
- $old_str = array ("\\n", '"', "<?php", "?>", "\\r" );
- $new_str = array ("", "'", "<?php", "?>", "" );
- $value = str_replace ( $old_str, $new_str, $value );
- $content .= "\\$" . $var . "['" . $key . "'] = \\"" . $value . "\\";\\n";
- }
- }
- return $content;
- }
- //该片段来自于http://www.codesnippet.cn/detail/19112012440.html
来源: http://www.codesnippet.cn/detail/19112012440.html