我正在尝试从
- 表:艺术家
- 行:艺术家
成这种格式。艺术家姓名可以有特殊字符,其中有超过 16k 个。它需要写入文件。例如称为任何artist.php
$Artist = array(
"Name from database",
"Name from database",
"Name from database",
"Name from database",
"Name from database"
);
好的抱歉没有解释。为 ajax 自动完成执行此操作。所以我需要在其中创建一个包含此数组的文件。
我让它工作并以我需要的方式输出它只是停留在如何在完成后将所有内容都说给文件。
这就是我所拥有的
require_once('config.php');
$res = mysql_query("SELECT artist FROM artists");
$ids = array();
$NotAllowed = array("(", ")", "+", ".", "-", "$", "#", "'", "\"", "%",":", ",", "*", "\\", "/");
echo '$aUsers = array('; echo "<br>";
while ($row = mysql_fetch_assoc($res)) {
$ids[] = $row['artist'];
$FixedArtist = str_replace($NotAllowed, " ", $row['artist']);
echo "\""; echo $FixedArtist; echo "\","; echo "<br>";
}
echo "\"Lastname\""; echo "<br>";
echo ");";
$FileToSaveTo = "ajax-search.php";
$fp = fopen($FileToSaveTo,"w") or die ("Error opening file in write mode!");
fputs($fp,$content);
fclose($fp) or die ("Error closing file!");