簡體   English   中英

如何獲取 JSON 響應 Laravel 8 中的變量計數

[英]How to Get Count of variable in JSON Response Laravel 8

我有這個 json 響應:

JSON 響應

如何獲得“成員”的數量,我嘗試了這個:

<tbody>
    @foreach ($datas as $post)
    <tr
        <td scope="row">{{ sizeof($post ->json-> members) }}</td>d>
    </tr>
   @endforeach
</tbody>

但我得到了這個錯誤:

ErrorException
sizeof(): Parameter must be an array or an object that implements Countable (View: C:\xampp\htdocs\firstapp\resources\views\s1.blade.php)

請問有什么幫助嗎?

我找到了解決方案,我在視圖中使用它:

@foreach ($datas as $post)
 <tr>
   <td scope="row">{{ count((explode(',', json_encode($post->json->members)))) }</td>
 </tr>
@endforeach
count(json_decode($post[0]->json->members, true));

我的錯。 對不起; 這里解決 count(json_decode(json_encode($post[0]->json->members), true));

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM