gpt4 book ai didi

php - 如何在点php之后和之前分隔数组

转载 作者:可可西里 更新时间:2023-11-01 14:02:53 25 4
gpt4 key购买 nike

我有一个这样的数组:

Array (
[0] => Array (
[tsk_hours_spent] => 23425.00
)
[1] => Array (
[tsk_hours_spent] => 2.00
)
[2] => Array (
[tsk_hours_spent] => 0.00
)
[3] => Array (
[tsk_hours_spent] => 0.00
)
[4] => Array (
[tsk_hours_spent] => 0.20
)
)

我希望根据“.”分隔结果分成两个数组

即,

点一阵前点一阵后例如:

第一个数组将是:23425,2,0,0,0

第二个数组将是:00,00,00,00,20

最佳答案

试试这个

<?php
$tsk_hours_spent = array(array('tsk_hours_spent'=>'23425.00'),array('tsk_hours_spent'=>'2.00'),array('tsk_hours_spent'=>'0.00'),array('tsk_hours_spent'=>'0.00'),array('tsk_hours_spent'=>'0.00'));

$finalArray = array();
foreach($tsk_hours_spent as $key){

$tmp = (explode('.',$key['tsk_hours_spent']));
$finalArray['partOne'][] = $tmp[0];
$finalArray['partSecond'][] = $tmp[1];

}
echo implode(',',$finalArray['partOne']);
echo "</br>";
echo implode(',',$finalArray['partSecond']);

关于php - 如何在点php之后和之前分隔数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22421357/

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