note 48968 deleted from ref.dom by didou
| From: | didou@php.net | Date: | Mon, 13 Mar 2006 00:00:22 +0000 |
| Subject: | note 48968 deleted from ref.dom by didou | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-105395@lists.php.net to get a copy of this message | ||
Note Submitter: rabarca[at]dcc[dot]uchile[dot]cl
----
to create a simple array from a plist (http://developer.apple.com/documentation/MacOSX/
Conceptual/BPRuntimeConfig/Concepts/ConfigFiles.html), you can use this modification from
timo[dot]goetze[at]electricpaper[dot]de's function:
<?php
function plist_to_array ($domnode, &$array, $name) {
$array_ptr = &$array;
$domnode = $domnode->firstChild;
while (!is_null($domnode)) {
if (! (trim($domnode->nodeValue) == "") ) {
switch ($domnode->nodeName)
{
case "dict": {
if ($name != "")
$array_ptr = &$array[$name][];
break;
}
case "key": {
if ($domnode->nodeValue != $name)
$name = $domnode->nodeValue;
break;
}
case "string": {
$array_ptr[$name] = $domnode->nodeValue;
break;
}
}
if ( $domnode->hasChildNodes() ) {
plist_to_array ($domnode, $array_ptr, $name);
}
}
$domnode = $domnode->nextSibling;
}
}
?>
so far it only works with string types, but you can extend it to the other common data types.