GMLscripts.com

Discuss and collaborate on GML scripts
Invert

You are not logged in.

#1 2018-09-12 09:53:58

idealcastle
Member
Registered: 2018-09-12
Posts: 9

ARRAY: in_array()

This is similar to the PHP version of "in_array(value, array)"

//  in_array(value,array)
//
//  Returns boolean of true/false 
//  checks if item is within the array or not
//
//      value       value to check, string
//      array       group of elements, array
//

var searchArray = argument[1];
var findValue = argument[0];   
   
var loop = 0;
repeat (array_length_1d(searchArray)) 
{	
	if (searchArray[loop++] == findValue) return true;
}

return false;

Offline

#2 2018-09-12 15:17:30

xot
Administrator
Registered: 2007-08-18
Posts: 1,195

Re: ARRAY: in_array()

Heheh, nice. I wrote something just like this yesterday for a project. Very useful. Thank you for the submission and welcome to the forums!


Abusing forum power since 1986.

Offline

#3 2018-09-12 20:50:35

idealcastle
Member
Registered: 2018-09-12
Posts: 9

Re: ARRAY: in_array()

No problem! Glad to be here. I've used game maker 1.4 many many years ago. I've been in web dev for a long time now, and im moving back into some game dev projects. Would love to help build up some resource. smile

Offline

Board footer

Powered by FluxBB