I've written a simple recursive function to convert trees like <*a* <*b*, *c*>, <*d*>> into PHP arrays like the corresponding one as generated by array (a, array (b, c), d) The resulting array construct is directly usable. Feel free to include the function in your own sources and modify it at will. I hereby release it under the bugroff license available from http://www.geocities.com/SoHo/Cafe/5947/bugroff.html this is the code: function free_to_array ($str) { $i = 0; while ($cursor < strlen ($str)) { while ( ($c = substr ($str, $cursor, 1)) == " " || $c == "\n" || $c == "," || $c == ".") $cursor ++; $match = $c; if ($c == "<") $match = ">"; $end = strpos ($str, $match, ++ $cursor); $level[$i] = substr ($str, $cursor, $end - $cursor); if ($c == "<") $level[$i] = free_to_array ($level[$i]); $cursor = $end + 1; $i ++; } return $level; } and a practical application example: xml_open ("test", "<*language*> <*JavaScript*>"); creating element/value pairs for use in XML-like documents without the syntax overhead of nested calls to arrays. D. Alvarez Arribas <[EMAIL PROTECTED]> >You have to write your own function for this. >> I want a function or macro to return executable code yielding syntax >> preprocessing of binary trees. Because the Macro Processor seems to be >> somewhat messy I though a regular function might be capable of doing the >> job. >> >> e.g. >> >> btree ('(("a", "b")("c", "d"))') >> >> should be expanded to >> >> array (array ("a", "b") >> array ("c", "d") >> >> >> How can I archieve this? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]