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
精彩评论