小编Mik*_*los的帖子

PHP四舍五入到小数点后第二位

通过计算面积,我有一个数字,我需要以一种奇怪的方式显示。

始终显示 2 个小数位。如果第 3 个以上的小数位 > 0,则始终向上舍入第 2 个小数位。

例子:

0.5 = 0.50
0.500003 = 0.51
0.96531 = 0.97
0.96231 = 0.97
0.8701 = 0.88
Run Code Online (Sandbox Code Playgroud)

是否有内置函数可以在 PHP 中执行此操作,还是我需要编写一个函数?

php rounding

3
推荐指数
2
解决办法
4148
查看次数

PHP-EWS在多个附件上失败

我使用James Armes的PHP-EWS库.

以下代码适用于单个附件,但与多个文件失败.

<?php
$msgRequest->MessageDisposition = 'SaveOnly';

$msgResponse = $ews->CreateItem($msgRequest);
$msgResponseItems = $msgResponse->ResponseMessages->CreateItemResponseMessage->Items;

// Create attachment(s)
$attachments = array();
$i = 0;
foreach ($message_details['attachment'] as $attachment) {
    $attachments[$i] = new EWSType_FileAttachmentType();
    $attachments[$i]->Content = file_get_contents($attachment['path'] . '/' . $attachment['file']);
    $attachments[$i]->Name = $attachment['file'];
    $i++;
}
//
// Attach files to message
$attRequest = new EWSType_CreateAttachmentType();
$attRequest->ParentItemId = $msgResponseItems->Message->ItemId;
$attRequest->Attachments = new EWSType_NonEmptyArrayOfAttachmentsType();
$attRequest->Attachments->FileAttachment = $attachments;

$attResponse = $ews->CreateAttachment($attRequest);
$attResponseId = $attResponse->ResponseMessages->CreateAttachmentResponseMessage->Attachments->FileAttachment->AttachmentId;

// Save message id from create attachment response
$msgItemId …
Run Code Online (Sandbox Code Playgroud)

php exchangewebservices php-ews

3
推荐指数
1
解决办法
738
查看次数

标签 统计

php ×2

exchangewebservices ×1

php-ews ×1

rounding ×1