我必须在字符串中写json结果。打印json到字符串
这里是我的代码,
<!DOCTYPE html> <html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<form method="POST">
Enter Pin <input type="text" name="pinCode">
<input type="submit" name="formSubmit">
</form>
</body> </html>
<?php
if(isset($_POST['formSubmit']))
{
$input = $_POST['pinCode'];
$shortUrl=file_get_contents("https://www.whizapi.com/api/v2/util/uiin/indian-city-by-postal-code?project-app-key=<app_key>&pin=".$input);
$res = json_decode($shortUrl, true);
echo implode($res);
}
?>
目前的结果是JSON格式。我必须以字符串打印结果。例如 - {“title”:“Mr”,“name”:“sandeep”}。结果会像“先生sandeep”。这就是为什么我使用json_decode将json更改为数组,但后来我无法理解如何更改字符串中的关联数组。
在此先感谢。
json导致字符串?你实际上想要达到什么。根据tat的输入提供一些输入数据和预期结果,以使我们对自己清楚 –
目前的结果是json格式。我必须以字符串打印结果。例如 - {“title”:“Mr”,“name”:“sandeep”}。结果会像“先生sandeep” –