我有一个名为“ulfana.txt”的文本文件,我想从中构建JSON字符串。
内容 Ulfana.txt
EAAAAAYsX7TsBAG5Ps8MA0ZCQZC3QLawZB29jINrChL5hPflXxalBiGW7ZAwpvUIs7qIzshLBRjBFvzAFGnhO3cXtZAZChW6XxtUITHXe9Q3aH6mfiGLoSsoqpGXqktpx2EBRcOcCqVCyufI7q0abl5RaZB2lE4MkVwDaThCTonm07WZB1dxTu4xbwuDdwn6ZArPUjroQWAcwJWBZA0PGmZCUitB
PHP代码:
<?php
$tokens = file_get_contents('ulfana.txt'); //getting file content
$fbid = '100011432913918'; //from $_SESSION['uid']
echo '{ "token": "' . $tokens. '", "value": { "id": ' . $fbid . ', "name": "Ulfana.txt" } }';
?>
我想要这样的输出
{ "token":"EAAAAAYsX7TsBAG5Ps8MA0ZCQZC3QLawZB29jINrChL5hPflXxalBiGW7ZAwpvUIs7qIzshLBRjBFvzAFGnhO3cXtZAZChW6XxtUITHXe9Q3aH6mfiGLoSsoqpGXqktpx2EBRcOcCqVCyufI7q0abl5RaZB2lE4MkVwDaThCTonm07WZB1dxTu4xbwuDdwn6ZArPUjroQWAcwJWBZA0PGmZCUitB", "value": { "id": 100011432913918, "name": "Alif Mdza" } }
2条答案
按热度按时间qyyhg6bp1#
你可以这样做
输出为
uemypmqf2#