About Array Functions

Array functions were introduced in ACF to simplify programming with fields and datasets. In this version of ACF, we support one-dimensional arrays exclusively. Arrays can significantly streamline certain programming tasks.

Declaration:

array string myArr;     // Declared with zero elements. 

// or an array with five elements: 
array string myArr = {"ell1", "ell2", "ell3", "ell4", "ell5"};

Getting the value count for an array:

array string myArr = {"ell1", "ell2", "ell3", "ell4", "ell5"};
int x = sizeof(myArr);  // should be 5

Adding elements to an array:

array string myArr = {"ell1", "ell2", "ell3", "ell4", "ell5"};
myArr[] = "ell6"; 

Accessing individual cells in an array:

array string myArr = {"ell1", "ell2", "ell3", "ell4", "ell5"};
print myArr[3];  // Should print "ell3" on the console. 

You cannot set individual cells outside the currently counted cells; otherwise, you will encounter an "array index..." error.

Merging two arrays:

array string myArr = {"ell1", "ell2", "ell3", "ell4", "ell5"};
array string myArr2 = {"ell6", "ell7", "ell8", "ell9", "ell10"};

array string myArr3 = {myArr, myArr2}; // All ten elements. The list may contain constant strings or single variables too, merged into myArr3. 

Also, consider exploring the Explode and Implode functions for more array manipulation options. The markdown example contains numerous array-related illustrations as well.