/** * Converts array to string with PHP code of this array * @param array $object * @param int $indent * @param string $type * @return string */ function fn_array2code_string($object, $indent = 0, $type = '') { $scheme = ''; if ($type == '') { if (is_array($object)) { $type = 'array'; } elseif (is_numeric($object)) { $type = 'integer'; } } if ($type == 'array') { $scheme .= "array("; if (is_array($object)) { if (!empty($object)) { $scheme .= " \n"; } foreach ($object as $k => $v) { $scheme .= str_repeat("\t", $indent + 1) . "'{$k}' => " . fn_array2code_string($v, $indent + 1) . ", \n"; } } $scheme .= str_repeat("\t", $indent) . ")"; } elseif ($type == 'int' || $type == 'integer') { if ($object == '') { $scheme .= 0; } else { $scheme .= $object; } } else { $scheme = "'{$object}'"; } return $scheme; }
public static function writeLog($data, $file = 'sberbank.log') { $path = fn_get_files_dir_path(); fn_mkdir($path); $file = fopen($path . $file, 'a'); if (!empty($file)) { fputs($file, 'TIME: ' . date('Y-m-d H:i:s', TIME) . "\n"); fputs($file, fn_array2code_string($data) . "\n\n"); fclose($file); } }
function fn_yandex_money_log_write($data, $file) { $path = fn_get_files_dir_path(); fn_mkdir($path); $file = fopen($path . $file, 'a'); if (!empty($file)) { fputs($file, 'TIME: ' . date('Y-m-d H:i:s', time()) . "\n"); fputs($file, fn_array2code_string($data) . "\n\n"); fclose($file); } }