I have an Android application, which creates a TXT file in PHP, bringing the XML form data from Android itself. Look at 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 data name, cpf, neighborhood, email and phone in an array, which returns the following data, since 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;