Авторизация
 Регистрация   Войти   Забыли пароль? 

settings_array_for_write(), array_write(), fwrite_file() Запись массива в файл. Запись любого текста в файл

Обновлённый PHP-Fusion Bogatyr / Free CMS PHP-Fusion 7 Bogatyr / PHP-functions for files upload and download / settings_array_for_write(), array_write(), fwrite_file() Запись массива в файл. Запись любого текста в файл


 Russian

settings_array_for_write(), array_write(), fwrite_file() Write an array to a file. Write any text to a file

Обновлённый PHP-Fusion Bogatyr / Free CMS PHP-Fusion 7 Bogatyr / PHP-functions for files upload and download / settings_array_for_write(), array_write(), fwrite_file() Write an array to a file. Write any text to a file


 English

PHP

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in F:\OpenServer\domains\php-fusion.vveb.ws\includes\bbcodes\mail_bbcode_include.php on line 20

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in F:\OpenServer\domains\php-fusion.vveb.ws\includes\bbcodes\mail_bbcode_include.php on line 21

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in F:\OpenServer\domains\php-fusion.vveb.ws\includes\bbcodes\search_bbcode_include.php on line 39
PHP
  1. <?php
  2. function settings_array_for_write($query=array(), $query_name ='query') {
  3.     $t="";
  4.     foreach ($query as $k=>$v) {
  5.          // echo " $".$query_name."['".$k."'] = stripslashes('".addslashes(stripslashes($v))."');\n<br>";
  6.         $t .=
  7. " $".$query_name."['".$k."'] = stripslashes('".addslashes(stripslashes($v))."');
  8. ";
  9.     }
  10.     return $t;
  11. }
  12. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  13. // преобразует одномерный массив в php-код и записывает в файл php
  14. function array_write($arr=array('a01'=>'1a3151', 'b2'=>'htl', 'ct62'=>'657'), $array_name='vk_sek', $s_http_host='php-func' ) {
  15.     $w = "<"."?php
  16. " . settings_array_for_write($arr, $array_name) . "
  17. ?".">";
  18.     @chmod ($array_name.'_'.$s_http_host.'.php', 0777);
  19.      fwrite_file($array_name.'_'.$s_http_host.'.php', $w);
  20.     @chmod ($array_name.'_'.$s_http_host.'.php', 0644);
  21. }
  22. function fwrite_file($file, $text) {
  23.     $temp = fopen($file, "w");
  24.     $r='';
  25.     if (fwrite($temp, $text)) {
  26.           //echo "<br> файл ".$file." сохранён\n";
  27.          $r=1; //$r=true;
  28.     } else {
  29.           //echo "<br> файл ".$file." <font color=red>НЕ</font> сохранён!\n";
  30.           $r=0; //$r=false;
  31.     }
  32.     fclose($temp);
  33.     if (file_exists($file))        @chmod($file, 0644);
  34.     return $r;
  35. }
  36. ?>
Добавить комментарий

Добавить комментарий
Пожалуйста, залогиньтесь для добавления комментария.
Рейтинги
HTML-code and BB-code for blogs and forums

<a href="https://php-fusion.vveb.ws/php-fusion.php?id=11">settings_array_for_write(), array_write(), fwrite_file() Запись массива в файл. Запись любого текста в файл</a>


[url=https://php-fusion.vveb.ws/php-fusion.php?id=11]settings_array_for_write(), array_write(), fwrite_file() Запись массива в файл. Запись любого текста в файл[/url]

Language: Default
 
Код для PHP-Fusion