This seems more concrete:
PHP Code:
function dictionaryToArrray() {
$args = func_get_args();
$str = '';
foreach($args as $arg) {
$pos = strpos($arg,':');
if($pos!==false) $str.= '\''.substr($arg,0,$pos).'\'=>'.substr($arg,($pos+1)).',';
}
eval('$properties = array('.rtrim($str,',').');');
return $properties;
}
echo '<pre>',print_r(dictionaryToArrray('a:"My String"','b:45','c:"Some other info"','d:6.4')),'</pre>';
Its going to be used to fill a ActiveRecord object.
PHP Code:
$record = new BlogEntry('title:"my title"','weight:0','user_id:2');
vs. (standard way)
PHP Code:
$record = new BlogEntry(array('title'=>'my title','weight'=>0,'user_id'=>2))
Bookmarks