gpt4 book ai didi

PHP二维数组转Javascript数组

转载 作者:行者123 更新时间:2023-12-01 01:58:37 25 4
gpt4 key购买 nike

我有 php 多维数组

 Array
(
[0] => Array
(
[WorkHrs] => 9826
[Focus_Date] => 2010-02-10
)

[1] => Array
(
[WorkHrs] => 9680
[Focus_Date] => 2010-02-11
)

)

我想将它在 Javascript 中转换为

 myArray = [['2010-02-10', 9826],['2010-02-11', 9680]];

最佳答案

$jsArray = array();
foreach($myArray as $array) {
$jsArray[] = array($array['Focus_Date'], (int) $array['WorkHrs']);
}

echo json_encode($jsArray);

关于PHP二维数组转Javascript数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3801370/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com