ImYourCousin Posted July 11, 2018 Share Posted July 11, 2018 Hi guys. I want count same string values on a JSON file. It looks like below. { "131": { "uyeid": "170", ... }, "71": { "uyeid": "170", ... }, "148": { "kurumid": "171", ... ... I get this content with below code $icerik = file_get_contents("json.php"); $veri = json_decode($icerik, true); I want count uyeid values in this json file.Is that possible? Quote Link to comment https://forums.phpfreaks.com/topic/307481-counting-same-values-in-json/ Share on other sites More sharing options...
Barand Posted July 11, 2018 Share Posted July 11, 2018 $veri = [ 131 => ['uyeid' => 170], 71 => ['uyeid' => 170], 148 => ['kurumid' => 171] ]; $uyeid_count = count(array_filter($veri, function($v) { return isset($v['uyeid']); })); echo $uyeid_count; //--> 2 1 Quote Link to comment https://forums.phpfreaks.com/topic/307481-counting-same-values-in-json/#findComment-1559565 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.