Re: working on array of different number of indices

From: Date: Wed, 16 May 2001 20:58:59 +0000
Subject: Re: working on array of different number of indices
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-53118@lists.php.net to get a copy of this message
Im not sure either what you mean. you want to know if a var is an array ? if (is_array($maybe_array)) if your looking for a way to transverse thought the array, use foreach() function work_on_array($value, $index) { if (is_array($index)) foreach($index as $pos => $val) $value[$pos] = some_func($value[$pos]); else $value[$index] = some_func($value[$index]); return $value; } this what your looking for ? -- Chris Lee lee@mediawaveonline.com "Dennis Gearon" <gearond@oit.edu> wrote in message news:3B02A086.EE5DCB8D@oit.edu... I want to pass in a scalar int, or an array of ints (indices) to a function in a class. The scalar or array will be a class variable. Without knowing the max size of each index, or the number of indices, (as is required is most other languages), I can't figure out how to access the array in a flexible fashion. What I **WANT** to use as a clue is whether the passed $index value is a scalar, or how many elements are in the array. examples: function work_on_array( $value, $index ){ blah to $this->value_s_holder; .. .. } work_on_array( 7, array(4,5) ); work_on_array( 23, 1 ); The number of INDICES will not change during program execution, although I do not want to have to predict the range of the scalar/indices. any ideas? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#53118) next »