如何将此表单PHP转换为AS3?
$arr = explode(" | ", $str);
foreach($arr as $item)
{
$arr2 = explode(": ", $item);
$finalArray[$arr2[0]] = $arr2[1];
}
该函数将此字符串转换为数组:
标题:Murk |标签:你好|胆碱受体: Lorem | Quelle:Ipsum |
由于
答案 0 :(得分:4)
它不是关联数组,但您可以使用Object执行此操作。类似的东西:
var str:String = "Title: Murk | Tags: Hello | Nachr: Lorem | Quelle: Ipsum";
var arr:Array = str.split(" | ");
var obj:Object = new Object();
for each (var s:String in arr) {
var a:Array = s.split(": ");
obj[a[0]] = a[1];
}
trace(obj.Title); // Murk