chris-ELM
2/28/2014 - 9:28 AM

Sub array checker

Sub array checker

var _arr:Array = ['1', '3~4', '2'];
trace(_arr.length);
var counter:Number = 0;
var _id:String = '4';

function arrCheck(_arrItem:String, _id) {
	var _tempArr:Array = _arrItem.split("~");
	var _ret:String;
	if (_arrItem.length > 1) {
		for (i = 0; i < _tempArr.length; i++) {
			//trace(_id + " | " + _tempArr[i]);
			if (_id == _tempArr[i]) {
				_ret = _tempArr[i];
			}

		}
	}
	trace(_ret);
	return _ret;

}

for (i = 0; i < _arr.length; i++) {
	if (_arr[i].length > 1) {
		if (_id == arrCheck(_arr[i], _id)) {
			counter++;
		}
	}
}

trace(counter);