XML => UID Associative Array

I found myself in need of ‘flattening’ an XML tree. Basically, I needed a means of storing XML elements in to database to search for results at a latter time. The following PHP code transforms the XML tree into an associative array with the following schema

$phparray[‘parent.child’][$i] = $value

Where $i would indicate the sibling number. The *combination* of the latter index and the sibling number conveniently constitute a primary key 🙂

Okay here’s the code…



$vals = array();


foreach($vals as $key=>$value)
foreach($value as $k=>$v)
print(“{$key}[{$k}] = {$v}

function RecurseXML($xml,&$vals,$parent=””)
$child_count = 0;
foreach($xml as $key=>$value)
$k = ($parent == “”) ? (string)$key : $parent . “.” . (string)$key;
if(RecurseXML($value,$vals,$k) == 0) // no childern, aka “leaf node”
$vals[$k][] = (string)$value;
return $child_count;

type[0] = Lunch
time[0] = 12:30
menu.entree[0] = salad
menu.entree[1] = chips
menu.maincourse[0] = steak


Suse + Apache sendmail from() address

Here’s a quick tidbit on setting the [default] from address for php [sendmail] on a suse box. There are *two* settings that need to be changed, let’s look at the default “out-of-the-box” email from address.

WWW daemon apache

The wwwrun is the username that is being used to send the email. (See /etc/apache2/uid.conf). To alter this value, we need to masquerade it.

Computer->YaST->Network Services->Mail Transfer Agent
Click Next
Click Masquerading
At the bottom of the screen click “Add”
Select local user `wwwrun`
Enter the desired ‘Display as’ value (i.e. webmaster@yourdomain.com)

OK out of the dialog and YaST.

If you send a mail now, it will have a ‘from’ address of

WWW daemon apache

To alter the full name `WWW daemon apache`, you’ll need to update the wwwrun user itself.

Computer->YaST->Security and Users->User Management

You may need to set the filter options to show ‘system’ users. Select the `wwwrun` user, click Edit and modify the `User’s Full Name` field.