如何使用PHP从数组值中减去时间?
我有这个数组。
$val = array(12:10, 4:16, 2:05);
我想从$ val
数组中减去14:00
hrs,从每个元素都不会像这样的元素变为负面的方式:
$val = array(0, 2:26, 2:05)
I have this array.
$val = array(12:10, 4:16, 2:05);
I want to subtract 14:00
hrs from the $val
array in the way that from every element that element do not become negative like this:
$val = array(0, 2:26, 2:05)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
更多
发布评论
评论(1)
我获得了从此 post 的功能您的问题的逻辑如下:
我们从输入值提取时间,直到输入值变为零或整个数组元素变为零(通过forloop)。
该解决方案还可以使用大于“ 24:00”的输入或数组元素值。
I get the function to extract time from this post and implement the logic for your problem as follows:
We substract the time from input value until the input value become zero or entire array elements become zero (by forloop).
This solution also works with input or array elements value greater than "24:00".