Posted by Rik on 02/07/07 15:06
Aggelos <djjelly@gmail.com> wrote:
> Hello,
> I am using php4
> And I have a class product
> I create an array of productObjects that has 2 dimensions.
> Generraly I am sorting my objects inside arrays and I need to some how=
> recurse those arrays to get to the objects.
>
> To do that I am using the following method recurseArray()
>
> function recurseArray($array) {
> if(is_array($array)) {
> foreach($array as $arrayValue) {
> recurseArray($arrayValue);
This won't do anything, you returned objects are cast in the void....
How would you like your objects returned by the function? In case of a =
flat array (which I suspect):
function objects_from_array($var){
$return =3D array();
if(is_object($var)){
$return[] =3D $var;
}
if(is_array($var)){
$return =3D array_merge($return,objects_from_array($var));
}
return $return;
}
-- =
Rik Wasmus
Navigation:
[Reply to this message]
|