我有一个来自 Wordpress 页面的数据库数组:
dev-user-20190424.php
<?php
$wb_users = array(
array(
"Username" => "Azmina",
"Level" => "form-5",
"School" => "KOLEJ D PATINGGI ABANG HJ ABDILLAH, SARAWAK",
"SchoolID" => 4522,
),
array(
"Username" => "Gudako",
"Level" => "form-5",
"School" => "KOLEJ D PATINGGI ABANG HJ ABDILLAH, SARAWAK",
"SchoolID" => 4522,
),
array(
"Username" => "Takatosaijo29",
"Level" => "form-5",
"School" => "SEKOLAH MENENGAH KEBANGSAAN BAHANG, SABAH",
"SchoolID" => 4210,
),
array(
"Username" => "Obon",
"Level" => "form-5",
"School" => "SEKOLAH MENENGAH KEBANGSAAN BAHANG, SABAH",
"SchoolID" => 4210,
),
array(
"Username" => "Rayana12",
"Level" => "form-5",
"School" => "SEKOLAH MENENGAH KEBANGSAAN BAHANG, SABAH",
"SchoolID" => 4210,
),
array(
"Username" => "kaiyuanbeh",
"Level" => "form-5",
"School" => "SEKOLAH MENENGAH KEBANGSAAN PERMATANG RAWA, PULAU PINANG",
"SchoolID" => 4250,
),
array(
"Username" => "Divyabharthi",
"Level" => "form-5",
"School" => "SEKOLAH MENENGAH KEBANGSAAN PETALING, WP KL",
"SchoolID" => 4244,
),
array(
"Username" => "blackchocolatecake",
"Level" => "form-4",
"School" => "SEKOLAH MENENGAH KEBANGSAAN POI LAM, PERAK",
"SchoolID" => 4375,
),
);
所以我想要实现的是通过循环数组 $wb-users 来显示另一个 WordPress 页面上的用户总数,如果 SchoolID 与当前用户学校 id 变量匹配,则对其进行计数。然后页面上会显示用户总数。
牧羊人nacy