• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

listtoarray with no value between delimiter

Contributor ,
May 25, 2014 May 25, 2014

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.

Views

624

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Contributor , May 27, 2014 May 27, 2014

Thanks a lot,

I stopped at CF8 doc,

I did not think that old functions have been improved.

Great.

Pierre.

Votes

Translate

Translate
Community Expert ,
May 25, 2014 May 25, 2014

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
May 26, 2014 May 26, 2014

Copy link to clipboard

Copied

My version of CF is 9.0.2

Thanks,

Pierre.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 26, 2014 May 26, 2014

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">

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
May 27, 2014 May 27, 2014

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 27, 2014 May 27, 2014

Copy link to clipboard

Copied

LATEST

De rien.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation