[{"dy_count":"5000","hit_num":"5000","negative_num":"0","negative_check_num":"0","risk_num":"0","gp_num":"100","beautiful_num":"500","date":"20230501","hit_rate":"1.0000","negative_check_number_rate":null,"risk_rate":"0.0000","gp_rate":"0.0200","beautiful_rate":"0.1000"},{"dy_count":"999","hit_num":"999","negative_num":"0","negative_check_num":"0","risk_num":"0","gp_num":"0","beautiful_num":"0","date":"20230503","hit_rate":"1.0000","negative_check_number_rate":null,"risk_rate":"0.0000","gp_rate":"0.0000","beautiful_rate":"0.0000"}]将dycount 单独放入一个数组用php实现
时间: 2023-07-02 11:21:29 浏览: 180
可以使用 PHP 的 `array_column` 函数,将 "dy_count" 这个键对应的值提取出来,组成一个新的数组。示例代码如下:
```php
$json_data = '[{"dy_count":"5000","hit_num":"5000","negative_num":"0","negative_check_num":"0","risk_num":"0","gp_num":"100","beautiful_num":"500","date":"20230501","hit_rate":"1.0000","negative_check_number_rate":null,"risk_rate":"0.0000","gp_rate":"0.0200","beautiful_rate":"0.1000"},{"dy_count":"999","hit_num":"999","negative_num":"0","negative_check_num":"0","risk_num":"0","gp_num":"0","beautiful_num":"0","date":"20230503","hit_rate":"1.0000","negative_check_number_rate":null,"risk_rate":"0.0000","gp_rate":"0.0000","beautiful_rate":"0.0000"}]';
$data = json_decode($json_data, true);
$dy_count_array = array_column($data, 'dy_count');
print_r($dy_count_array);
```
输出结果为:
```
Array
(
[0] => 5000
[1] => 999
)
```
阅读全文