Hello

I have a soap call that returns something like;

Result from a print_r();

stdClass Object ( [getCategoryTreeReturn] => Array ( [0] => stdClass Object
( [iId] => 1 [sName] => Cars & Motorbikes [iParentId] => 0 [iTreeCount] =>
114302 [iLocalCount] => 0 [aSubCats] => Array ( [0] => stdClass Object (
[iId] => 2 [sName] => Car Electronics [iParentId] => 1 [iTreeCount] => 0
[iLocalCount] => 0 ) [1] => stdClass Object ( [iId] => 5 [sName] => Car
Accessories [iParentId] => 1 [iTreeCount] => 57160 [iLocalCount] => 57142 )
[2] => stdClass Object ( [iId] => 16 [sName] => Motorcycles [iParentId] => 1
[iTreeCount] => 11 [iLocalCount] => 0 )

I need to convert that to a multidimensional array to link ID's to Parent
ID's. I have created a function which recursively scans the result variable.
It writes the rows to a temporary file for later fetching, but it is
somewhat slow. Can i maintain those recursive seek to an array. As function
is being called inside and inside, i can not return a proper value. Is there
any way to maintain those rows without writing to tmp.


The function is :

--- BEGIN ---

function deepseek($val) {

foreach ($val as $key => $value) {

        if (is_object($value)) {
        $newarr = get_object_vars($newarr);
                foreach ($newarr as $key2 => $value2) {
                deepseek($value2);
                }
        }

        if (is_array($value)) {

                foreach ($value as $key2 => $value2) {
                deepseek($value2);
                }
        }

        if (!is_array($value) AND !is_object($value)) {

                if ($key == "iParentId" OR $key == "sName" OR $key == "iId") {

                $output .= "$value-";

                }

                if ($key == "iTreeCount") {
                $handle = fopen("tmp/tmp","a");
                fwrite($handle,$output."\n");
                fclose($handle);

                unset($output);

                }


        }

}


}
--- END ---

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to