【发布时间】:2018-05-04 17:41:05
【问题描述】:
返回的对象 API 中包含点、空格和 %。如何删除或重命名这些键。
array:61 [▼
"status" => 0
"NetRange" => "31.0.0.0 - 31.255.255.255"
"CIDR" => "31.0.0.0/8"
"OrgName" => "RIPE Network Coordination Centre"
"OrgId" => "RIPE"
"Address" => "P.O. Box 10096"
"City" => "Amsterdam"
"StateProv" => ""
"PostalCode" => "1001EB"
"Country" => "NL"
"Referral.Server" => "whois://whois.ripe.net"
"Org Abuse.Handle" => "ABUSE3850-ARIN"
"Org Abuse.Name" => "Abuse Contact"
"Org Abuse.Phone" => "+31205354444"
"Org Abuse.Email" => "abuse@ripe.net"
"Org Abuse.Ref" => "https://whois.arin.net/rest/poc/ABUSE3850-ARIN"
"Org Tech.Handle" => "RNO29-ARIN"
"% Org Tech.Ref" => "https://whois.arin.net"
"inetnum" => "31.13.69.0 - 31.13.69.255"
"netname" => "IAD1"
"descr" => "Facebook"
"country" => "US"
"admin-c" => "RD4299-RIPE, PH4972-RIPE"
"tech-c" => "RD4299-RIPE, PH4972-RIPE"
"mnt-by" => "fb-neteng, fb-neteng"
"mnt-lower" => "fb-neteng"
"mnt-routes" => "fb-neteng"
"created" => "2014-06-11T18:46:37Z, 2011-04-11T18:49:50Z"
"last-modified" => "2014-06-11T18:46:37Z, 2013-08-14T15:49:58Z"
"source" => "RIPE, RIPE # Filtered"
"role" => "RIPE DBM"
"address" => "1601 Willow Rd., Menlo Park, CA, 94025"
"nic-hdl" => "RD4299-RIPE"
"abuse-mailbox" => "domain@fb.com"
"% This query was served by the RIPE Database Query Service version 1.91.2 (ANGUS)" => ""
"cidr_mask" => array:1 [▶]
]
例如将键 Org Abuse.Handle 更改为 OrgAbuseHandle 并将 % Org Tech.Ref 更改为 OrgTechRef。
【问题讨论】:
-
我猜想你使用任何其他键的方式相同。您应该能够正常访问这些密钥,因此设置一个新密钥并取消设置旧密钥。
-
也许如果您发布了不起作用的代码,我们可以告诉您原因。
-
感谢您的评论。我正在使用 mongodb,如果字段包含 .、$、%,它们对插入有一些限制,所以我想在插入之前重命名它,或者如果键包含点或任何特殊字符,则将其删除。