사용 JSON. 데이터를 쉽게 편집 할 수 있습니다 (멋진 기능이기 때문에).
if (empty($_POST['pizzaCount']) === false && empty($_POST['city']) === false)
{
$savePath = 'folder/folder2/save.txt';
$content = array();
//does the file already exist?
if (($fileContents = file_get_contents($savePath)) !== false)
{
//get the old data
$content = json_decode($fileContents , true);
}
//add the new data
$content[] = array('pizzaCount' => $_POST['pizzaCount'] , 'city' => $_POST['city']);
//decode the new data
$content = json_encode($content);
file_put_contents($savePath , $content);
}
왜 텍스트 파일입니까? 데이터베이스가 더 좋은 아이디어가 아닌가? –
왜냐하면 난 그냥 아주 간단한 일이 필요해 – Gregg
Google에 PHP 파일을 입력하는 것이 간단하지 않습니까 ?? ?? ?? 3 초 후에 http://goo.gl/w7Yyj – Star