Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function save_file($file, $content, $chmod = 0777) {
- if (is_array($file))
- rename($file[0], $file[1]);
- else
- $file = array(1 => $file);
- $data = fopen($file[1], 'w');
- fputs($data, '<?php return '.create_file_array($content).';?>');
- fclose($data);
- @chmod($file[1], $chmod);
- }
- function create_file_array($array) {
- $final_data = '';
- foreach ($array as $key => $value) {
- if (is_array($value))
- $final_data .= '\''.$key.'\'=>'.create_file_array($value).',';
- elseif (is_bool($value)) {
- if ($value)
- $value = 'true';
- else
- $value = 'false';
- }
- elseif (is_int($value) || is_float($value))
- $value = (string) $value;
- else
- $value = '\''.$value.'\'';
- $final_data .= '\''.$key.'\'=>'.$value.',';
- }
- return 'Array('.rtrim($final_data, ',').')';
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement