1
I have an Android application, which creates a TXT file in PHP, bringing the data from the XML form of Android itself. See the code:
$f = fopen('POST_DATA.txt', 'a');
fwrite($f, 'ID: '.$id."\r\n");
$id = uniqid( time() );
fwrite($f, 'Nome: '.$_POST['nome']."\r\n");
fwrite($f, 'Cpf: '.$_POST['cpf']."\r\n");
fwrite($f, 'Bairro: '.$_POST['bairro']."\r\n");
fwrite($f, 'E-mail: '.$_POST['email']."\r\n");
fwrite($f, 'Telefone: '.$_POST['telefone']."\r\n\r\n");
fclose($f);
I would like to play the name data, Cpf, neighborhood, email and phone in an array, which returns the following data, because the query below I can already read it on Android:
$json_str = '{"usuarios": '.'[{"nome":"Felipe", "bairro": São Pedro, "cpf": "11111111", "email" : "[email protected]", "telefone" : "222222222"},'.']}';
//faz o parsing da string, criando o array "empregados"
$jsonObj = json_decode($json_str); $empregados = $jsonObj->empregados;
echo $json_str;
Why not save the json itself to the txt file? takes some library/function that identa it when saving to txt.
– Skywalker