Eli Stone
Eli Stone

Reputation: 1555

AS3: Remove and add to variable after a character

I am pulling data from a php script that gives me the names of a person on facebook along with there ID in this format:

Person Name:123456789

I would like to know if there is a away to split after the ":" and add the number (ID) to on array and the person name to another array.

Thanks for any help Eli

Upvotes: 1

Views: 244

Answers (1)

Corey
Corey

Reputation: 5818

Something like this:

var personArray:Array = [];
var idArray:Array = [];
var stringToSplit:String = "Person Name:123456789";
var splitArray:Array = stringToSplit.split(":");

personArray.push(splitArray[0]);
idArray.push(splitArray[1]);

trace(personArray); // outputs "Person Name"
trace(idArray); // outputs "123456789"

Upvotes: 3

Related Questions