Status
Not open for further replies.
xml/array conversion in php
PHP:
<?php
class XmlArray {
    static function xmlObjToArr($obj) { 
        return json_decode(json_encode($obj), true);
    } 
    
    
    static function arrToXmlObj($root_element_name,$array) 
    { 
        $xml = new SimpleXMLElement("<?xml version=\"1.0\"?><{$root_element_name}></{$root_element_name}>"); 
        $f = function($f,$c,$a) { 
                foreach($a as $k=>$v) { 
                    if(is_array($v)) { 
                        $ch=$c->addChild($k); 
                        $f($f,$ch,$v); 
                    } else { 
                        $c->addChild($k,$v); 
                    } 
                }
        };
        $f($f,$xml,$array); 
        return $xml->asXML(); 
    }
}
?>
 
Bringing this thread back...


A snippet of me using threadpools to load large images into pictureboxes quickly in vb.net:
Code:
For Each kvp As KeyValuePair(Of StreamTypes, Stream) In e.resultStream
	Select Case kvp.Key
		Case 0 'key = StreamTypes.Picture
			fontImage = Image.FromStream(kvp.Value)
			ThreadPool.QueueUserWorkItem(AddressOf loadPicture)
		Case 1 'key = StreamTypes.Chart
			fontChartImage = Image.FromStream(kvp.Value)
			ThreadPool.QueueUserWorkItem(AddressOf loadChart)
	End Select
Next kvp
 
Status
Not open for further replies.
Back
Top