Zac*_*Zac 5 arrays coldfusion cfquery
我可以将数组拆分成两个独立的数组,原始数组中的每个元素用":"分隔吗?":"之前的文本转到array1,":"之后的文本转到array2
<cfset tempArr = DeserializeJSON(URL.data) />
<cfset selectList = "" />
<cfloop array=#tempArr# index="i">
<cfset selectList = listappend(selectList,i) />
</cfloop>
Run Code Online (Sandbox Code Playgroud)
现在,这段代码抓住了整个元素,而不是分开.
编辑
示例字符串将是:
FIRST_NAME:鲍勃
first_name进入selectList1 Bob进入selectList2
宏伟的计划同样会有其他领域:
FIRST_NAME:鲍勃
姓氏:Shmo
年龄:27
等等...
编辑:答案
通过使用代码解决了问题
<!---Variables--->
<cfset temp1 = "" />
<cfset temp2 = "" />
<cfset selectList1 = "" /><!---Holds column names for tables--->
<cfset selectList2 = "" /><!---Holds query parameters for column names. Ie,
values for use in the WHERE clause--->
<cfloop array=#tempArr# index="i"><!---Loop through contents of the array--->
<cfset temp1 = GetToken(i,1,":")/><!---Store the column name--->
<cfset temp2 = GetToken(i,2,":")/><!---Query parameter--->
<cfset selectList1 = listAppend(selectList1, temp1)/><!---Adds to list of column names--->
<cfset selectList2 = listAppend(selectList2, temp2)/><!---Adds to the list of query parameters--->
</cfloop>
Run Code Online (Sandbox Code Playgroud)
我想如果没有看到你的数组示例,你的意思是将数组中的数据拆分为两个列表?
<cfset selectList1 = listAppend(selectList1, listFirst(i,':')) >
<cfset selectList2 = listAppend(selectList2, listLast(i,':')) >
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
786 次 |
| 最近记录: |