我有一个包含诸如这些名称的数组变量;
// Listing ENTITIES
$entitiesTable = array(
1 => "user",
2 => "group",
3 => "customer",
4 => "supplier",
5 => "terminal",
6 => "order",
7 => "invoice",
8 => "invoice detail",
9 => "invoice offer",
10 => "invoice offer detail",
11 => "quotation",
12 => "quotation detail",
13 => "quotation offer",
14 => "quotation offer detail",
15 => "purchase order",
16 => "purchase order detail",
17 => "purchase order request",
18 => "purchase order request detail",
19 => "sales order",
20 => "sales order detail",
21 => "delivery order",
22 => "delivery order detail",
23 => "sales return",
24 => "sales return detail",
25 => "purchase return",
26 => "purchase return detail",
27 => "item",
28 => "category",
29 => "unit measurement",
30 => "last activity",
31 => "rack",
32 => "alert",
33 => "filter",
34 => "prefix code",
35 => "system",
36 => "company profile"
);
在我的 php 主体的中间,我创建了 For 循环。迭代数组,然后回显它们。
foreach ($entitiesTable as $singleEntity){
if(preg_match($regexUsed, $singleEntity)){
$pluralEntity = preg_replace($regexUsed, 'ies', $singleEntity);
} else {
$pluralEntity = $singleEntity . 's';
}
// Replacing spaces with a dash character and capitalize the first word
$pluralEntityWOSpace = ucwords($pluralEntity);
$pluralEntityWOSpace = str_ireplace(" ","" , $pluralEntityWOSpace);
$pluralEntityWDash = str_ireplace(" ","-" , $pluralEntity);
$singleEntityWOSpace = ucwords($singleEntity);
$singleEntityWOSpace = str_ireplace(" ","" , $singleEntityWOSpace);
echo $singleEntityWOSpace . '<br/>';
}
不知何故,我现在才意识到,我得到的不是一个完整的名称,因为它是前面从数组中列出的。相反,我现在得到的只是这些名字的一小部分。看!这是我获得的输出名称:
User
Group
Customer
Supplier
Terminal
Order
Invoice
InvoiceDetail
InvoiceOffer
InvoiceOfferDetail
Quotation
QuotationDetail
QuotationOffer
QuotationOfferDetail
PurchaseOrder
PurchaseOrderDetail
PurchaseOrderRequest
PurchaseOrderRequestDetail
SalesOrder
SalesOrderDetail
DeliveryOrder
DeliveryOrderDetail
SalesReturn
SalesReturnDetail
PurchaseReturn
PurchaseReturnDetail
Item
Category
UnitMeasurement
LastActivit
我试图在我的php 脚本末尾写FLUSH(),并且这些名称的输出是好的。但它给了我另一个错误,因为我使用的是Slim Framework。除了使用FLUSH()之外,还有其他替代方法吗?