我正在尝试将循环的结果添加到数组中。
这是我的代码:
<cfset mobNumbers = ArrayNew(1)>
<cfloop query = "staffLoop">
<cfscript>
mobileNo = staffLoop.mobileno;
mobileNo = mobileNo.replaceAll("[^0-9]", "");
ext = staffLoop.extension;
ext = ext.replaceAll("[^0-9]", "");
if (Left(mobileNo, 2) == "07" || Left(mobileNo, 3) == "447") {
recipient = mobileNo;
} else if (Left(ext, 2) == "07" || Left(ext, 3) == "447") {
recipient = ext;
} else {
recipient = "";
}
if (Left(recipient, 2) == "07") {
recipient = "447" & Right(recipient, Len(recipient) - 2);
}
if (Len(recipient) == 12) {
[send text code]
}
</cfscript>
</cfloop>
<cfset ArrayAppend(mobNumbers, "recipient")>
目标是获取所有手机号码的数组。
我的代码不工作,我经过一些研究,我不知道该怎么做。有任何想法吗?
如果可能的话,我想为我的解决方案使用非 cfscript,但如果使用 cfscript 更容易,那很好。