我希望我就在这里。Json PHP输出数字(整数)
我从一个JSON文件制作一个搜索引擎,把我的数据(URL) 我可以读出我的代码文本(PHP)
<?php
foreach ($obj['Products'] as $key => $value) {
echo '<p>Artikel: '.$value['ProductName']. '</p> <br/>';
echo '<p> Produktbeschreibung: '.$value['Description'].'</p> <br/><br/>';
echo '<a href="' .$value['Deeplink1'].'" target="_blank"> zum Shop </a><br/><br/>';
}
$service = "http://dateck-media.de/sf/ddd.php ;This is the JSON // Put together request $request = $service . "?" . http_build_query($params); Get response $response = file_get_contents($request,TRUE); $obj = json_decode($response,true);
但现在我想显示我的搜索结果。在我的JSON文件,它看起来像
Array (
[ProductsSummary] => Array (
[Records] => 20
[TotalRecords] => 41
[TotalPages] => 3
[CurrentPage] => 1
)
[Products]
我不知道如何让[Totalrecords]
在我的代码来呼应"You have [TotalRecords] for your search"
请帮助我。
搜索结果的数量,我的意思是!我需要在我的html文件中使用TotalRecords => 41 –
如果您的JSON文件看起来像这样,它不是JSON。此外,您提供的代码似乎与您的问题无关。那个代码有问题吗?你能提供你的JSON文件的确切内容,以及如何转换它? – trincot
$ service =“https://product-api.affili.net/V3/productservice.svc/JSON/SearchProducts”;这是JSON //放在一起请求 $ request = $ service。 “?” 。 http_build_query($ params)方法;获取回复 $ response = file_get_contents($ request,TRUE); $ obj = json_decode($ response,true); –