File: /www/wwwroot/www.kntsleep.com/bbbb/1.php
<?php
// 原始数据
$data = '[{"id":1714984679,"status":1,"wx":"44","link":"https:\/\/api.whatsapp.com\/send\/?phone=447469693207&text=I+need+advice+about+weight+loss.&type=phone_number&app_absent=0","click":0,"show":0,"totalshow":0,"select":0},{"id":1714984671,"status":0,"wx":"333","link":"https:\/\/api.whatsapp.com\/send\/?phone=447469693207&text=I+need+advice+about+weight+loss.&type=phone_number&app_absent=0","click":0,"show":0,"totalshow":0,"select":0},{"id":1714983922,"status":1,"wx":"222","link":"https:\/\/api.whatsapp.com\/send\/?phone=447469693207&text=I+need+advice+about+weight+loss.&type=phone_number&app_absent=0","click":1,"show":2,"totalshow":2,"select":0},{"id":1714983917,"status":1,"wx":"111","link":"https:\/\/api.whatsapp.com\/send\/?phone=447469693207&text=I+need+advice+about+weight+loss.&type=phone_number&app_absent=0","click":1,"show":1,"totalshow":1,"select":0}]';
// 解码 JSON 数据
$array = json_decode($data, true);
// 定义排序函数
function sortByStatus($a, $b) {
return $a['status'] - $b['status'];
}
// 使用 usort 函数进行排序
usort($array, 'sortByStatus');
// 遍历排序后的数组
foreach ($array as $item) {
echo "ID: " . $item['id'] . ", Status: " . $item['status'] . "\n";
}
?>