Copy link to clipboard
Copied
Reading lines in a text file,
Listing a text file , with value between ;
sometime , there is no data between 2 ; which I need to know.
In that case, (when there is no value between the delimiter) my array have a different length (smaller)
Then the data order is not good.
As I want to save in a DataBase, I do not know what data in what field number ?
Thanks for any help,
Pierre.
Thanks a lot,
I stopped at CF8 doc,
I did not think that old functions have been improved.
Great.
Pierre.
Copy link to clipboard
Copied
Do you mean that you want to express "a;b;;c;;;d" as a list of 7 elements. If so, then the best solution depends on your ColdFusion version. Recent versions take account of missing list elements between delimiters. What is your version?
Copy link to clipboard
Copied
My version of CF is 9.0.2
Thanks,
Pierre.
Copy link to clipboard
Copied
In ColdFusion 9, the third argument of the function listToArray, includeEmptyFields, instructs ColdFusion whether or not to include blank list elements. A demo follows:
<cfset list = "a;b;;c;;;d">
<!--- Include blank list elements --->
<cfset array1 = listToArray(list,";",true)>
<cfdump var="#array1#" label="Include blank list elements">
<br>
<!--- Exclude blank list elements --->
<cfset array2 = listToArray(list,";",false)>
<cfdump var="#array2#" label="Exclude blank list elements">
Copy link to clipboard
Copied
Thanks a lot,
I stopped at CF8 doc,
I did not think that old functions have been improved.
Great.
Pierre.
Copy link to clipboard
Copied
De rien.