<doc>
	<legacy_id>3517</legacy_id>
	<name>arrayEncode</name>
	<type>function</type>

	<syntax>
		<example>arrayEncode(array,[version])</example>
		<example></example>
	</syntax>

	<synonyms>
	</synonyms>

	<summary>Serializes a LiveCode array.</summary>

	<examples>
<example><p>savePreferencesData "displayOptions", arrayEncode(sDisplayOptionsArray)</p></example>
<example><p>write urlEncode(arrayEncode(tArray)) to socket tSocket</p></example>
<example><p></p></example>
<example><p></p></example>
<example><p></p></example>
	</examples>

	<history>
		<introduced version="3.5">Added.</introduced>
		<deprecated version=""></deprecated>
		<removed version=""></removed>
		<changed version="7.0">Optional version parameter added</changed>
		<experimental version=""></experimental>
		<nonexperimental version=""></nonexperimental>
	</history>

	<objects>
	</objects>

	<platforms>
		<mac/>
		<windows/>
		<linux/>
		<ios/>
		<android/>
	</platforms>

	<classes>
		<desktop/>
		<server/>
		<web/>
		<mobile/>
	</classes>

	<security>
	</security>


	<classification>
		<category>Writing LiveCode</category>
		<category></category>
	</classification>

	<references>
		<function tag="arrayDecode">arrayDecode function</function>
		<function tag="keys">keys function</function>
		<command tag="write to socket">write to socket command</command>
		<keyword tag="[]">[] keyword</keyword>
	</references>

	<description>
	<overview>Use the <b>arrayEncode</b> function to convert an array into a string so that it can be saved to a file or sent across a network.</overview>

		<parameters>
<parameter>
<name>array</name>
<description>The array is a LiveCode array.</description> 
</parameter>
<parameter>
<name>version</name>
<description>If present, and >= "7.0" then the array is encoded in such a way as to preserve unicode in keys and values, as well as NUL chars in keys and values</description> 
</parameter>		</parameters>

	<value>The <b>arrayEncode</b> function returns a string of binary data that represents the data and structure of the specified array.</value>
	<comments><p>The string returned by the arrayEncode function is designed to be used to transfer arrays to remote machines or to save them to a file on disk. It is an opaque, binary encoding of the data contained in the array. The original array can be rebuilt by using the arrayDecode function. Encoded arrays cannot easily be modified, and should always be converted back into real arrays before attemping to access or modify them. </p><p></p><p>To send an encoded array to a remote process over TCP/IP, it should be encoded using the URLEncode function, as it may contain characters not suitable for use in URLs.</p><p></p><p><b>Note:</b> Arrays in LiveCode are un-ordered. This means in particular that encoding two arrays will not necessarily produce the same result, even if the arrays had the same elements. To compare two arrays, simply use the = operator directly on them rather than encoding them first.</p><p></p></comments>
	</description>
</doc>