PHP Classes

File: doc.txt

Recommend this page to a friend!
  Classes of zinsou A.A.E.Moïse   PHP Dictionary to Array class   doc.txt   Download  
File: doc.txt
Role: Documentation
Content type: text/plain
Description: documentation
Class: PHP Dictionary to Array class
Manipulate value collections as arrays or objects
Author: By
Last change:
Date: 6 years ago
Size: 19,978 bytes
 

Contents

Class file image Download
public function __call($name, $arguments) the purpose of __call ( implemented just to avoid fatal errors) public static function __callStatic($name, $arguments) the purpose of __callStatic implemented just to avoid fatal errors public function __construct($offset=1,$prefix='',$strict=true,$return_array_type=false,$limitnumber=false) xDict constructor public function __debugInfo() the purpose of __debugInfo public function __get($property) the purpose of __get public function __invoke() the purpose of __invoke (this method allows the xDict object to act as callable which actually accept an infinite number of arguments and add the value of each argument to the xDict object.However ,when the value is iterable then each value of this argument will be add separately to the xDict object.So if the behavior wished is to add the value of a such argument once it is better to use the push method) public function __isset($property) the purpose of __isset public function __set($property,$value) the purpose of __set (allows actually to change only strict ,start,prefix,limitnumber,return_array_type) public static function __set_state($array) the purpose of __set_state public function __toString() return a json version of the current xDict object public function __unset($property) the purpose of __unset implemented just to avoid fatal errors public function avg() return the average of the numeric values in the xDict object public function arsort($sort_flags =SORT_REGULAR )the purpose of arsort public function asort($sort_flags =SORT_REGULAR ) the purpose of asort public function change_key_case ($case=CASE_LOWER) the purpose of array_change_key_case public function chunk ($size,$preserve_keys = false ) the purpose of array_chunk public function clear() clear the xDict object to make isEmpty return true public function column ($column_key,$index_key = null) the purpose of array_column public function combine ($values) the purpose of array_combine public function compact(...$varnames) the purpose of compact (this method is particular for it adds the compacted values to the current xDict object instead of created a new one) public function contains(...$values) determine whether or not the current xDict object contains a set of values public function copy() return a shallow copy of the current xDict object public function count() the purpose of countable::count public function count_values() the purpose of array_count_values (this method is particular for it uses a really different approach to count values and thus allows to count any type of value) public function current() the purpose of current public function depth() return the depth of the current xDict object private function detectleveltype($string) useful for the SetInnerVal and UnsetInnerVal methods ,it return an array of variables types for each level of the previous formatted string eg: [0][1]['astring'] will return an array containing the types for all the level if the $this[0][1]['astring'] really exists we could have array('array','array','string') public function diff(...$arrays) the purpose of array_diff public function diff_assoc (...$arrays) the purpose of array_diff_assoc public function diff_key (...$arrays) the purpose of array_diff_key public function diff_uassoc ($iterable2[,$iterable...],$key_compare_func) the purpose of array_diff_uassoc public function diff_ukey ($iterable2[,$iterable...],$key_compare_func) the purpose of array_diff_ukey public function dump() the purpose of var_dump($this); public function each() the purpose of each public function end() the purpose of end public function explode($delimiter,$string,$limit=PHP_INT_MAX) the purpose of explode (this method is particular for it create an array from the specified string and $delimiter exactly as the PHP explode function and then add the values to the xDict object.So call explode on an empty xDict object is just use the method fill_with of this empty object with the standard explode function as argument and will create and will make the object be like the xDict version of an array built with the PHP explode function) public function export($return=false) the purpose of var_export($this); public function extract($extract_type=EXTR_OVERWRITE,$prefix='') the purpose of extract public function fill_with($array,$preserve_keys_if_possible=true) take in parameter an iterable variable and fill the xDict object with its values.The keys can be preserved or not. public function filter ($callback=null,$flag=0) the purpose of array_filter public function first() reset the xDict object and return the first value. public function flip($anytype=TRUE,$collision_prefixed=tRUE) the purpose of array_flip (this method is particular for it allows to flip the xDict keys and the values even if there are invalid types of variable as object, resource ,array and float in the the set of values.It generate an hash for each invalid type except for float which simply change in string,to allow them as valid offsets .It also allows to rename offsets if collisions occurred) private static function getsquarebracket($string) this method is the complementary of the the method detectleveltype for it splits in array of levels a previous formatted string eg: for '[0][1][2]["maybeastring"][6][1]["etc"]' the output of the function will be array('[0]','[1]','[2]','["maybeastring"]','[6]','[1]','["etc"]'). public function hash() the purpose of spl_object_hash($this); public static function help($method=null) get a list of all the defined methods and their purpose or just the purpose of a precise method public function homogeneous(&$type=null) determine whether or not the xDdict object is homogeneous public function in_xdict($needle,$strict=true) the purpose of in_array public function insert($index, ...$values) insert a set of values any where in the xDict object specifying an existing offset public function intersect($iterable2[,$iterable...]) the purpose of array_intersect public function intersect_assoc($iterable2[,$iterable...]) the purpose of array_intersect_assoc public function intersect_key($iterable2[,$iterable...])the purpose of array_intersect_key public function intersect_uassoc ($iterable2[,$iterable...],$key_compare_func) the purpose of array_intersect_uassoc public function intersect_ukey ($iterable2[,$iterable...],$key_compare_func) the purpose of array_intersect_ukey public function isEmpty() the purpose of empty($array) public function join($glue='',$anytype=true) the purpose of join or implode public function jsonSerialize() the purpose of JsonSerializable::jsonSerialize public function key() the purpose of key public function key_exists($key) the purpose of array_key_exists public function keys($searchvalue='',$strict=false) the purpose of array_keys public function krsort($sort_flags =SORT_REGULAR ) the purpose of krsort public function ksort($sort_flags =SORT_REGULAR ) the purpose of ksort public function listvar(&...$varnames) the purpose of list (this method is particular for it does not allow null values as the list structure, only variables names) public function map ($callback ,...$arrays) the purpose of array_map public function max() the purpose of max public function mb_split($pattern,$string,$limit=-1) the purpose of mb_split (this method is particular for it create an array from the specified string and $pattern exactly as the PHP mb_split function and then add the values to the xDict object.So call mb_split on an empty xDict object is just use the method fill_with of this empty object with the standard mb_split function as argument and will create and will make the object be like the xDict version of an array built with the PHP mb_split function) public function merge(...$arrays) the purpose of array_merge public function merge_recursive (...$arrays) the purpose of array_merge_recursive public function min() the purpose of min public function multisort(Iterable &$array1 [, mixed $array1_sort_order = SORT_ASC [, mixed $array1_sort_flags = SORT_REGULAR [, mixed $... ]]] ) the purpose of array_multisort( public function natcasesort() the purpose of natcasesort public function natsort() the purpose of natsort public function next() the purpose of next private function normalizeRotations($r) return a normalize integer value forn the rotate method public function offsetExists($offset) the purpose of Iterator::offsetExists public function offsetGet($offset) the purpose of Iterator::offsetGet public function offsetSet($offset, $value) the purpose of Iterator::offsetSet public function offsetUnset($offset) the purpose of Iterator::offsetUnset public function pad ($size ,$value) the purpose of array_pad public function pop() the purpose of array_pop public function preg_filter($pattern,$replacement,$limit=-1,&$count=null) the purpose of preg_filter public function preg_grep($pattern,$flags=0) the purpose of preg_grep public function preg_replace($pattern,$replacement,$limit=-1,&$count=null) the purpose of preg_replace public function preg_replace_callback($pattern,$callback,$limit=-1,&$count=null) the purpose of preg_replace_callback public function preg_replace_callback_array($patterns_and_callbacks,$limit=-1,&$count=null) the purpose of preg_replace_callback_array public function preg_split($pattern,$string,$limit=-1,$flags=0) the purpose of preg_split (this method is particular for it create an array from the specified string and $pattern exactly as the PHP preg_split function and then add the values to the xDict object.So call preg_split on an empty xDict object is just use the method fill_with of this empty object with the standard preg_split function as argument and will create and will make the object be like the xDict version of an array built with the PHP preg_split function) public function prev() the purpose of prev public function print_or($offset) the purpose of print_r($xdictobject[$offset]) public function print_xr() the purpose of print_r($xdictobject) public function printx() the purpose of echo($xdictobject->__toString()) public function product() the purpose of array_product (this method is particular for it can be used without error on set of data which contains any type of variables the invalid types as array,resource and object will simply be replaced by 1 ). public function pseudoMiddle($interval_if_not_exists_in=false) you already know the PHP max() and min() functions the purpose of this method is to find the intermediate value between the values of these two functions called on the xDict object. eg: [0,1,2,3,4,5] min=0,max=5, middle=2.5, pseudoMiddle=2 or psedoMiddle=[2,3] eg: [0,1,2.5,3,4,5] min=0,max=5, middle=2.5, pseudoMiddle=2.5 note that the values do not need to be sorted ascending or descending but can be shuffled too the result will be the same. To make it simple the method return only the existing values in the current xDict object which are the closest to the middle value. public function push(...$mixed) the purpose of array_push public function pushColumn($name,$mixed) add a new column with the name $name to the xDict object or change the values of the column with the name $name (this method is useful but strict and must be used a clever way,for instance the number of values must be equals to the number of rows in the object if the object is not empty,$name must be string or integer,$mixed must be an array of values or an iterable object and it is better to use it on an object designed for the rows and columns selection. However if the object is not well designed but the requirements are met the column will be added. During the adding if a value is not an array it will be change into a column with the name #); public function rand($num=1) the purpose of array_rand public function range($low,$high,$step) the purpose of range (this method is particular for it create an array for the specified range and step exactly as the PHP range function and then add the values to the xDict object.So call range on an empty xDict object is just use the method fill_with of this empty object with the standard range function as argument and will create and will make the object be like the xDict version of an array built with the PHP range function) public function rcombine ($values ) the purpose of array_combine but it use the keys instead of values in the xDict object. public function reduce($callback , $initial = NULL) the purpose of array_reduce public function reindex() re-index the xDict object public function replace (Iterable...$array2) the purpose of array_replace public function replace_recursive (Iterable...$array2) the purpose of array_replace_recursive public function reverse($preserve_keys=false) the purpose of array_reverse (this method is particular for it can preserve the xDict object keys and allows to reindex to). public function rewind() reset the pointer of xDict object public function rotate($rotations) rotate the values in the Xdict object public function rowsandcol(&$ksignature=null) return whether or not the xDict object is suitable for rows and columns selection. public function rsort($sort_flags =SORT_REGULAR ) the purpose of rsort public function search($needle,$strict=false) the purpose of array_search public function SetInnerVal($rowandoffset,$value) add a new inner value (or change an existing one) to the xDict object (this method is useful but strict and must be used a clever way,. During the adding if a value is not an array but required to be an array to allow the specified insertion,it will be change into an entry of the new created array with the name #); objects implementing the arrayAccess interface do not allow this: $object["anoffset"][]=true the purpose of this method is thus to allow that, this way $object->SetInnerVal('["anoffset"]["newone"]',true); and you can use it on the first level or on any deep level eg: $object->SetInnerVal("[0][1][0]['suffix']['verydeep'][1][3][4]['new']",range(0,7)); public function shift($reindex=false) the purpose of shuffle (this method is particular for it preserve by default the xDict object keys and allows to reindex to). public function shuffle($preserve_keys=true) the purpose of shuffle (this method is particular for it can preserve the xDict object keys). public function signature() determine the signature of the current xDict object public function slice($offset,$length=false,$preserve_keys=false) the purpose of array_slice (this method is particular for it starts splicing always on offset and can take any type of variable as offset). public function sort($sort_flags =SORT_REGULAR ) the purpose of sort public function splice ($offset,$length=0,$replacement=array()) the purpose of array_splice (this method is particular for it starts splicing always on offset and can take any type of variable as offset). public function str_ireplace($search,$replace,&$count=null) the purpose of str_ireplace public function str_replace($search,$replace,&$count=null) the purpose of str_replace public function str_split($string,$split_length=1) the purpose of str_split (this method is particular for it create an array from the specified string and $split_length exactly as the PHP str_split function and then add the values to the xDict object.So call str_split on an empty xDict object is just use the method fill_with of this empty object with the standard str_split function as argument and will create and will make the object be like the xDict version of an array built with the PHP str_split function) public function substr_replace($replace,$start,$length) the purpose of substr_replace public function sum() the purpose of array_sum (this method is particular for it can be used without error on set of data which contains any type of variables the invalid types will simply be ignored). public function swap ($off1,$off2) swap the values of two offsets public function toArray() the purpose of spl function iterator_to_array public function typesof() determine the types of variables used in the current xDict object public function uasort($value_compare_func) the purpose of uasort public function udiff ($iterable2[,$iterable...],$data_compare_func) the purpose of array_udiff public function udiff_assoc ($iterable2[,$iterable...],$data_compare_func) the purpose of array_udiff_assoc public function udiff_uassoc ($iterable2[,$iterable...],$data_compare_func,$key_compare_func) the purpose of array_udiff_uassoc public function uintersect($iterable2[,$iterable...],$data_compare_func) the purpose of array_uintersect public function uintersect_assoc ($iterable2[,$iterable...],$data_compare_func) the purpose of array_uintersect_assoc public function uintersect_uassoc ($iterable2[,$iterable...],$data_compare_func,$key_compare_func) the purpose of array_uintersect_uassoc public function uksort($key_compare_func) the purpose of uksort public function unique ($sort_flags = SORT_STRING ) the purpose of array_unique public function unsetColumn($column) the opposite of pushColumn,remove the column $column from the xDict object public function unsetInnerVal($rowandoffset) objects implementing the arrayAccess interface do not allow this: unset($object["anoffset"]["here"]) the purpose of this method is thus to allow that, this way $object->unsetInnerVal('["anoffset"]["here"]'); and you can use it on the first level or on any deep level eg: $object->unsetInnerVal("[0][1][0]['suffix']['verydeep'][1][3][4]"); and even if there is an object implicated provided that the row and the offset exists. public function unshift(...$mixed) the purpose of array_unshift public function usort($value_compare_func) the purpose of usort public function valid() the purpose of valid public function values() the purpose of array_values public function walk ($callback, $userdata = NULL ) the purpose of array_walk_recursive public function walk_recursive ($callback, $userdata = NULL ) the purpose of array_walk_recursive private static function xcompact($v,$reset=true) return an array to use in the compact method private static function xdepth($array,$reset=true) determine the depth of an array private static function xtypesof($array,$reset=true) determine the types of variables used in an array private static function xsignature($array) determine the signature of an array