Re: Please have a look at proposed package draft : MultiArray

From: Date: Fri, 07 Jan 2005 18:24:40 +0000
Subject: Re: Please have a look at proposed package draft : MultiArray
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-35405@lists.php.net to get a copy of this message
Hello Selcuk, Great thing. I prefer to have this among common PHP functions. Some picky things from me if you need them, of course. =) > // {{{ _args2value() > /** > * Makes an extracted array from mixed input > * > * @param mixed $mArgument > * @param integer $iStart integer of start position > * > * @return array > * > * @access private > * @static > * @since Method available since Release 0.1 > */ > * Makes an extracted array from mixed input Can you describe more populat - what is "extracted array" and why it must be "made" and not "extracted"? > * @param mixed $mArgument From this function block I've got an idea what this is some magic function which makes array value from some garbage and takes arguments. I can't even tell you how to choose a good name for that function, because this comment is suitable to more than 50% of functions. $iStart is useless for me, because it is better to operate with sliced input/output than to implement $start, $end, input/output array in one function. My proposal.. // {{{ _makeflat() /** * Makes a flat (one dimensional array) from mixed input * * @param mixed $input any, really any * * @return array * @static * @since MultiArray-0.0.1 */ function _makeflat($input) { $aResult = array(); $aArg = array_values((array)$input); $iCnt = count($aArg); for ($i=0; $i<$iCnt; $i++) { if (is_array($aArg[$i])) { $aResult = array_merge($aResult, MultiArray::_makeflat($aArg[$i])); } else { $aResult[] = $aArg[$i]; } } return $aResult; } // }}} Next function IMHO doesn't worth complication. Could you provide a working example, where func_get_args() complication will be absolutely necessary. > // {{{ is_multiarray() ... > if ($argCol !== false) { > $aArg = MultiArray::_args2value(func_get_args(), 1); > } If one can write a PHP file with a call to this function with three or five arguments, (s)he can as well make an array from these. isMultiArray IMHO should be checkArray, because primary function is to validate array and not to figure out if array is multidimensional. Also I'd like to check more complex structures - like presence of some fields on specified depth of array. Ideally MA should be easily converted to PEAR::Tree and vice versa. > // {{{ maGroupBy() > /** > * Set column value of contained multidimensional array as index > * Until there will be tests to show input and output of this function, I'm unable to tell how this can be named. Perhaps even something like makehashby() - rebuild array using specified field as a key NOTE: if duplicated values are found later will be used BTW, do you have any 3D arrays examples? This proposal looks like Array2D =) php examples will be extremely helpful.. // {{{ maToArray() ? make1D() Everything else is ok for now. To tell the truth I just don't have enough time. =) P.S. Idea is great, but it's still Array2D =) SA> Hello everybody, SA> I want to present you the class "MultiArray". It is a class, which can SA> handle multidimensional arrays. See: SA> http://www.pear.php.net/pepr/pepr-proposal-show.php?id=185 SA> For example it can sort and filter multidimensional arrays using several SA> parameters, you can see it at work here: SA> SA> http://www.scalan.de/home/entwicklung/multiarray/beispiele/10737,10736,1,0.html SA> Any and all comments and feedback are welcome. SA> Greetings, SA> Selcuk Alan t --

« previous php.pear.dev (#35405) next »