开发者

Convert PHP Explode String to AS3

How to convert this form PHP to AS3?

$arr = explode(" | ", $str);
foreach($arr as $item)
{
    $arr2 = explode(": ", $item);
    $finalArray[$arr2[0]] = $arr2[1];
}

The function is to turn this string into an array:

Title: Murk | Tags: Hello | Nachr: Lorem | Quelle: I开发者_如何学Cpsum |

Thanks


It won't be an associative array, but you can do this with an Object. Something like:

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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜