Quote:
Originally Posted by moosewanted
Hey,
Probably really simple but I can't find any information.
I have a value which is stored in an array, but I want to find out it's position in the array and then use this new number.
Example:
PHP Code:
new g_Array[33]
public some_function(id) { g_Array[id] = 232 }
public some_other(array_value) { //I have the array value 232, but I want to find the id(position) in the array }
Thanks for help
|
To find and replace a value in an array:
PHP Code:
public ReplaceInArray( iArray[] , iFind , iReplace )
{
for ( new i = 0 ; i < sizeof iArray ; i++ )
{
if ( iArray[i] == iFind )
{
iArray[i] = iReplace;
break;
}
}
}
}
To find the index of an item in an array:
PHP Code:
public FindPosition( iArray[] , iVal )
{
for ( new i = 0 ; i < sizeof iArray ; i++ )
if ( iArray[i] == iVal )
return i;
}
__________________