<?xml version="1.0"?><phpdoc><class name="Bs_Array" extends="Bs_Object" undoc="false" access="public" package="util"><file>C:/usr/local/lib/php/blueshoes-4.2/core/util/Bs_Array.class.php</file><doc><author>Andrej Arn &amp;lt;andrej at blueshoes dot org&amp;gt;</author><inherited src="Array"/><description>knowledge base:o) some of php&amp;apos;s array functions (eg array_pop()) renumber the index of vectors.o) the syntax &amp;quot;$array[&amp;apos;someObject&amp;apos;]-&amp;gt;someFunction()&amp;quot; works now.no dependencies here.</description><shortdescription>This static class provides many useful array methods that don&amp;apos;t come with php.</shortdescription><version>4.0.$id$</version><copyright>blueshoes.org</copyright></doc><function name="explode" undoc="false" access="public"><doc><parameter name="$separator" type="array"/><parameter name="$string" type="string">//</parameter><parameter name="$limit" default="0" type="integer">(default is 0 which means &amp;apos;no limit&amp;apos;.)</parameter><return name="" type="array"/><description>example: you want to explode on &amp;apos; &amp;apos; and &amp;apos;-&amp;apos; at once. crap. with thismethod it&amp;apos;s a nap.$result = Bs_Array-&amp;gt;explode(array(&amp;apos; &amp;apos;, &amp;apos;-&amp;apos;), &amp;apos;this is your-string&amp;apos;);will give you array(&amp;apos;this&amp;apos;, &amp;apos;is&amp;apos;, &amp;apos;your&amp;apos;, &amp;apos;string&amp;apos;)you can also just do $result = split(&amp;apos;[ -]&amp;apos;, &amp;apos;this is your-string&amp;apos;);thus i&amp;apos;m not sure if that method is needed at all :/ (thanks to rick).</description><shortdescription>similar to php&amp;apos;s explode but can explode on multiple strings at once.</shortdescription></doc></function><function name="maxSizeOfLevel" undoc="false" access="public"><doc><parameter name="$array" type="array"/><parameter name="$level" type="int"/><return name="" type="int"/><throws>int 0 if $array is not an array or empty.&#x0a;@2do currently only supports levels 1 and 2.</throws><description>example:$array = array(0 =&amp;gt; array(&amp;apos;one&amp;apos;, &amp;apos;two&amp;apos;, &amp;apos;three&amp;apos;),1 =&amp;gt; array(&amp;apos;one&amp;apos;, &amp;apos;two&amp;apos;),2 =&amp;gt; array(&amp;apos;one&amp;apos;, &amp;apos;two&amp;apos;, &amp;apos;three&amp;apos;, &amp;apos;four&amp;apos;))maxSizeOfLevel($array, 1)  will return 3, that&amp;apos;s like a sizeOf().maxSizeOfLevel($array, 2)  will return 4.it makes no sense to use $level=1.</description><shortdescription>returns the max size of elements of an array</shortdescription></doc></function><function name="merge" undoc="false" access="public"><doc><return name="" type="array"> (may be empty)</return><description>this is similar to php&amp;apos;s array_merge, but behaves a bit different:php&amp;apos;s function sucks in that it fucks up the keys (index) of the arrayssometimes. read the user comments on php.net about it.example:$arrOne = array(&amp;apos;&amp;apos;=&amp;gt;&amp;apos;&amp;apos;);$arrTwo = array(&amp;apos;9&amp;apos;=&amp;gt;&amp;apos;apple&amp;apos;, &amp;apos;15&amp;apos;=&amp;gt;&amp;apos;banana&amp;apos;, &amp;apos;20&amp;apos;=&amp;gt;&amp;apos;grapefruit&amp;apos;);$result = array_merge($arrOne, $arrTwo);now $result is array(&amp;apos;&amp;apos;=&amp;gt;&amp;apos;&amp;apos;, &amp;apos;0&amp;apos;=&amp;gt;&amp;apos;apple&amp;apos;, &amp;apos;1&amp;apos;=&amp;gt;&amp;apos;banana&amp;apos;, &amp;apos;2&amp;apos;=&amp;gt;&amp;apos;grapefruit&amp;apos;); in php 4.1.1 (see ecg &amp;apos;syntax&amp;apos; file)$result = Bs_Array-&amp;gt;merge($arrOne, $arrTwo);now $result is array(&amp;apos;&amp;apos;=&amp;gt;&amp;apos;&amp;apos;, &amp;apos;9&amp;apos;=&amp;gt;&amp;apos;apple&amp;apos;, &amp;apos;15&amp;apos;=&amp;gt;&amp;apos;banana&amp;apos;, &amp;apos;20&amp;apos;=&amp;gt;&amp;apos;grapefruit&amp;apos;);as for array_merge: If the input arrays have the same string keys, then the later value for thatkey will overwrite the previous one.so: if you want to merge 2 numeric arrays and don&amp;apos;t care about the index (keys) then you haveto use array_merge().if one of the given params is not an array, it will be ignored.</description><shortdescription>merges 2 arrays.</shortdescription></doc></function><function name="arrayToCode" undoc="false" access="public"><doc><parameter name="&amp;$array" type="array">(hash or vector, any construct)</parameter><parameter name="$name" default="&amp;apos;$array&amp;apos;" type="string">default is &amp;apos;array&amp;apos; the name to use as the var name in the returned php code.</parameter><return name="" type="string"> @throw  empty string if param $array is not an array or empty.</return><description>example:$array  = array(&amp;apos;tom&amp;apos;, array(&amp;apos;fruit&amp;apos;=&amp;gt;&amp;quot;tom&amp;apos;s apple is \&amp;quot;green\&amp;quot;&amp;quot;), $object, array(15=&amp;gt;20), array());$string = arrayToCode($array, &amp;apos;$foo&amp;apos;);now $string looks like$foo[&amp;apos;0&amp;apos;] = &amp;quot;tom&amp;quot;;$foo[&amp;apos;1&amp;apos;][&amp;apos;fruit&amp;apos;] = &amp;quot;tom\&amp;apos;s apple is \&amp;quot;green\&amp;quot;&amp;quot;;$foo[&amp;apos;2&amp;apos;] = &amp;apos;&amp;apos;;$foo[&amp;apos;3&amp;apos;][&amp;apos;15&amp;apos;] = 20;$foo[&amp;apos;4&amp;apos;] = array();caution  I: objects are shown as empty strings. this is not serialize().caution II: the param $name needs to come with the $ sign. if you use &amp;quot;\$name&amp;quot; instead of &amp;apos;$name&amp;quot; you have to escape the $ sign.note:       string values are escaped.</description><shortdescription>takes an array and returns a php code string from it.</shortdescription></doc></function><function name="inArray" undoc="false" access="private"><doc><parameter name="$needle" type="string"/><parameter name="$haystack" type="array"/><parameter name="$ignoreCase" default="TRUE," type="string">(case insensitive search.)</parameter><parameter name="$ignoreSpaces" default="TRUE" type="string">(spaces (etc) in $haystack and $needle are ignored using trim().)</parameter><return name="" type="bool"/><description>similar to php&amp;apos;s in_array() function but this one is used for stringsonly and is able to ignore case and/or spaces. the &amp;apos;strict&amp;apos; param is of nouse here. if you don&amp;apos;t need ignorecase or ignorespaces then you are betteroff with php&amp;apos;s function, which must be faster.moves the pointer of $haystack, but does not change values. so you maypass the array by reference.example:$array = array(&amp;apos;abc&amp;apos;, &amp;apos; HELLO &amp;apos;);inArray(&amp;apos;hello&amp;apos;); returns TRUE.</description><shortdescription>tells if the value $needle is a value of the array $haystack.</shortdescription></doc></function><function name="max" undoc="false" access="public"><doc><see type="function">max()</see><parameter name="$array" type="array">vector or hash holding numbers</parameter><parameter name="$what" default="&amp;apos;value&amp;apos;" type="string">(one of &amp;apos;value&amp;apos; (default) or &amp;apos;key&amp;apos; which means if you want the key or value of the max element returned.)</parameter><return name="" type="mixed"> (for &amp;apos;value&amp;apos;: double   for &amp;apos;key&amp;apos;: string)</return><throws>bool FALSE (if not an array</throws><throws>or no numeric value at all.)</throws><description>only values that are numeric are taken into account.and this is the difference to:http://www.php.net/manual/en/ref.array.php david@preform.dk 01-Feb-1999 12:30use the max function to get the highest value of an array e.g:$maxval = max($array);php&amp;apos;s min() and max() treats bool FALSE as the smallest value. we only use numericvalues.note   I: this method moves the pointer of the array. you may pass the param by ref.note  II: not using php&amp;apos;s sort functions here. maybe code may be speed-optimized.note III: if 2 or more numbers are equal (and the max) and you want the &amp;apos;key&amp;apos; returnedthen only the first key is returned.php offers array_sum() but not this. i guess it will be there somewhen.example:$array   = array(&amp;apos;en&amp;apos;=&amp;gt;5, &amp;apos;fr&amp;apos;=&amp;gt;7, &amp;apos;de&amp;apos;=&amp;gt;3);$maxNum  = max($array);$maxLang = max($array, &amp;apos;key&amp;apos;);</description><shortdescription>returns the highest number that exists in the array.</shortdescription></doc></function><function name="min" undoc="false" access="public"><doc><see type="function">min()</see><parameter name="$array" type="array">vector or hash holding numbers</parameter><parameter name="$what" default="&amp;apos;value&amp;apos;" type="string">(one of &amp;apos;value&amp;apos; (default) or &amp;apos;key&amp;apos; which means if you want the key or value of the max element returned.)</parameter><return name="" type="mixed"> (for &amp;apos;value&amp;apos;: double   for &amp;apos;key&amp;apos;: string)</return><throws>bool FALSE (if not an array</throws><throws>or no numeric value at all.)</throws><description>see $this-&amp;gt;max() there is more information.</description><shortdescription>returns the smallest number that exists in the array.</shortdescription></doc></function><function name="randVal" undoc="false" access="public"><doc><parameter name="$array" type="array">array you can think of.</parameter><return name="" type="mixed">a randomly selected element of the array, by value.</return><description>note: maybe you better use php&amp;apos;s array_rand() for your needs.if no or an empty array was given, an empty string is returned.example:$hello = &amp;apos;world&amp;apos;;$foo   = &amp;apos;bar&amp;apos;;$x = $Bs_String::randVal(array(&amp;$hello, &amp;$bar));it&amp;apos;s intentional that the param $array is taken by value and notby reference. this way you can use a syntax like the one above inthe example. otherwise you&amp;apos;d have to do$x = $Bs_String::useOneOfArray($array = array($hello, $bar));which is less optimized especially for big array elements.</description><shortdescription>Return one of the given elements of the array randomly.</shortdescription></doc></function><function name="getLastKey" undoc="false" access="public"><doc><parameter name="$array" type="array"/><return name="" type="mixed">the last/highest key, so it&amp;apos;s an int or a string.</return><description>if $array is an associative array, it&amp;apos;s the last one. if $array is a &amp;apos;normal&amp;apos;indexed array, it&amp;apos;s an int.note: if you&amp;apos;re going to pass the $array param by reference, be aware of thefact that this method moves the pointer to the end.</description><shortdescription>Get the last (highest) key from an array.</shortdescription></doc></function><function name="setPos" undoc="false" access="public"><doc><parameter name="&amp;$array" type="array">(hash or vector)</parameter><parameter name="$findKey" type="mixed">(int or string)</parameter><return name="" type="bool">TRUE if key was found, FALSE if not (pos will be after the last element)</return><description>we hope that php comes with such a function sometime.</description><shortdescription>sets the pointer to the given key (hash or vector)</shortdescription></doc></function><function name="getPos" undoc="false" access="public"><doc><parameter name="$array" type="array"/><parameter name="$find" type="mixed">(the value to find)</parameter><parameter name="$findKey" default="TRUE," type="string">(where to look, TRUE means key while FALSE means value.)</parameter><parameter name="$ignoreCase" default="FALSE" type="string">(if you want to ignore the case for the compare. default is FALSE.)</parameter><return name="" type="int"> (0-n)</return><throws>bool FALSE (if not found)</throws><description>the position starts with 0, not 1.example:$array = array(&amp;apos;3&amp;apos;=&amp;gt;&amp;apos;viola&amp;apos;, &amp;apos;7&amp;apos;=&amp;gt;&amp;apos;sam&amp;apos;, &amp;apos;9&amp;apos;=&amp;gt;&amp;apos;rick&amp;apos;, &amp;apos;12&amp;apos;=&amp;gt;&amp;apos;fab&amp;apos;);$pos = $Bs_Array-&amp;gt;getPos(&amp;$array, &amp;apos;7&amp;apos;);                 //will return 1$pos = $Bs_Array-&amp;gt;getPos(&amp;$array, &amp;apos;RICK&amp;apos;, FALSE, TRUE); //will return 2you may pass the $array by ref, but be aware that the pointer will bemoved to somewhere.</description><shortdescription>returns the numeric position of a given key or value in the given array.</shortdescription></doc></function><function name="guessType" undoc="false" access="public"><doc><parameter name="$array" type="array"/><return name="" type="string">one of &amp;apos;hash&amp;apos;, &amp;apos;vector&amp;apos;, &amp;apos;hash_guess&amp;apos;, &amp;apos;vector_guess&amp;apos;&#x0a;@throw NULL if param is not an array at all, FALSE if array is empty.</return><description>arrays in php are great fun. but there&amp;apos;s one thing.. these 2 arrays areexactly the same, so once created you cannot tell the difference:array(&amp;apos;0&amp;apos;=&amp;gt;&amp;apos;foo&amp;apos;, &amp;apos;1&amp;apos;=&amp;gt;&amp;apos;bar&amp;apos;)array(&amp;apos;foo&amp;apos;, &amp;apos;bar&amp;apos;)even the fact that &amp;apos;0&amp;apos; and &amp;apos;1&amp;apos; were written as strings and not 0 and 1as integers does not help; they are converted.it&amp;apos;s possible and i can think of cases where someone creates an associativearray with integer keys, they don&amp;apos;t need to be strings.if the key is not numeric, it&amp;apos;s 100% sure that it&amp;apos;s associative. if it&amp;apos;s numeric,and the first key has the value 0, we return a guessed zero-based. otherwisea guessed associative-based.note: if you&amp;apos;re going to pass the $array param by reference, be aware of thefact that this method moves the pointer to somewhere out in the green ...example:if (substr($Bs_Array-&amp;gt;guessType($myArray), 0, 6) == &amp;apos;vector&amp;apos;) echo &amp;apos;most likely a vector&amp;apos;;</description><shortdescription>Guess the array type. associative or not.</shortdescription></doc></function><function name="&amp;padding" undoc="false" access="public"><doc><parameter name="$array" type="array">above</parameter><parameter name="$pad_string" default="&amp;apos; &amp;apos;" type="string">(opt) see above (default &amp;apos; &amp;apos;)</parameter><parameter name="$pad_length" default="0" type="integer"/><parameter name="$pad_type" type="string" undoc="true"/><return type="void"/><description>to the specifed padding length. If length is 0 or not set, the size of longest stringin the array will be used as length.Optional argument pad_type can beSTR_PAD_RIGHT, STR_PAD_LEFT, or STR_PAD_BOTH.If pad_type is not specified it is assumed to be STR_PAD_RIGHT.NOTE: You may pass array by reference for direct changes.</description><shortdescription>This functions pads the input array of strings on the left, the right, or both sides</shortdescription></doc></function><function name="&amp;hashKeysToLower" undoc="false" access="public"><doc><parameter name="&amp;$hashArray" type="array"/><return name="" type="array">with all keys to lower case</return><description>Transform all keys of a hash array to lower caseNOTE: If 2 keys have the same value after modification, the second overwrites the first.</description><shortdescription>**********************************************************************</shortdescription><deprecated>use the new php function array_change_key_case() (php4 cvs only 2002/03/12 --andrej)</deprecated></doc></function><function name="&amp;hashKeysToUpper" undoc="false" access="public"><doc><parameter name="&amp;$hashArray" type="array"/><return name="" type="array">with all keys to upper case</return><description>Transform all keys of a hash array to upper caseNOTE: If 2 keys have the same value after modification, the second overwrites the first.</description><shortdescription>**********************************************************************</shortdescription><deprecated>use the new php function array_change_key_case() (php4 cvs only 2002/03/12 --andrej)</deprecated></doc></function><function name="splitKeyValue" undoc="false" access="public"><doc><parameter name="$array" type="array">(hash or vector)</parameter><return name="" type="array"> (see example)</return><description>example:$array = (&amp;apos;name&amp;apos;=&amp;gt;&amp;apos;fab&amp;apos;, &amp;apos;sex&amp;apos;=&amp;gt;&amp;apos;m&amp;apos;);list($keys, $values) = splitKeyValue($array);//now $keys = array(&amp;apos;name&amp;apos;, &amp;apos;sex&amp;apos;) and $values = array(&amp;apos;fab&amp;apos;, &amp;apos;m&amp;apos;)</description><shortdescription>returns the keys and values of the given array separated in 2 arrays.</shortdescription></doc></function><function name="Bs_Array" undoc="true" access="public"><doc><return type="void"/></doc></function><function name="uniqueArray" undoc="true" access="private"><doc><parameter name="$array" undoc="true"/><return type="void"/></doc></function><function name="array_rand" undoc="true" access="private"><doc><parameter name="$array" undoc="true"/><parameter name="$array" undoc="true"/><parameter name="$array" undoc="true"/><parameter name="$array" undoc="true"/><parameter name="$array" undoc="true"/><parameter name="$array" undoc="true"/><parameter name="$array" undoc="true"/><return type="void"/></doc></function><function name="array_change_key_case" undoc="true" access="private"><doc><parameter name="&amp;$hashArray" undoc="true"/><parameter name="&amp;$hashArray" undoc="true"/><parameter name="&amp;$hashArray" undoc="true"/><parameter name="&amp;$hashArray" undoc="true"/><parameter name="&amp;$hashArray" undoc="true"/><parameter name="&amp;$hashArray" undoc="true"/><parameter name="&amp;$hashArray" undoc="true"/><return type="void"/></doc></function><constant name="BS_ARRAY_VERSION" undoc="true" access="private" case="default: case sensitive">4.0.$x$<doc></doc></constant><inherited src="Bs_Object" type="functions"><element>isex</element><element>isexception</element><element>tostring</element><element>tohtml</element><element>persist</element><element>unpersist</element><element>bs_object</element><element>bbsetoutput</element><element>bbawake</element><element>bbisawake</element><element>bbxmsg</element><element>bbxfunctionstart</element><element>bbxfunctionend</element><element>bbxecho</element><element>bbxvar</element><element>bbxvardump</element><element>bbforcetrace</element><element>bbbufferstart</element><element>bbbufferget</element><element>bbbufferendflush</element><element>bbbufferendclean</element></inherited><inherited src="Bs_Object" type="consts"><element>bs_object_version</element></inherited><path><parent>Bs_Object</parent></path><baseclass>Bs_Object</baseclass></class></phpdoc>